I can't figure out why my Raspberry Pi will not auto-run a program on startup. I've tried everything that I can find. The Pi boots and runs the program fine with a monitor plugged in, but as soon as I unplug the monitor and reboot the program will no longer run.

From what I have gathered the desktop environment can't load without an HDMI connection. These are the things that I have tried:

Adding hdmi_force_hotplug=1 in the config.txt file.

Enabling VNC.

Manually forcing the display settings in the config.txt file.

Setting to boot in GUI and CLI.

Forcing the screen resolution.

Disabling the GL Driver.

Reinstalling the OS.

Trying an HDMI dummy plug.

I'm desperate as it's a semester project for college, and I just can't get this thing going.

  • 1
    You have said you tried lots of things but failed to show your code, what OS or how you tried to get it to run.
    – Milliways
    Commented Apr 10 at 22:00
  • 1
    It might be helpful for you to have a log for the program you are trying to open. Without that or at least some other information such as what you are using to "auto-run" your program on startup, then the answers here will be based on assumptions.
    – Adamq
    Commented Apr 10 at 23:16
  • If you haven't flunked out of college yet, I wonder if you've considered using cron to "autorun your program"? I also find it noteworthy that you claim to be "desperate", but won't bother to respond to two comments you got.
    – Seamus
    Commented Apr 16 at 16:49

1 Answer 1


Perhaps your program has a "cannot open display" error. If this is the case, then you can set the DISPLAY environment variable:

env DISPLAY=:0 your-program-name >> log-file.txt


export DISPLAY=:0;
your-program-name >> log-file.txt

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.