I have a Raspberry Pi B running a fresh install of PIXEL that I'm trying to connect to headless, within my own network. When I connect with a monitor, I have no issues - I can use RealVNC viewer from another device perfectly.

But when I restart the device headless, I cannot connect. Specifically I get an error: "The connection was refused by the host computer". I have created a virtual desktop using the instructions at VNC, but I cannot connect.

Again, plugging the same device with no changes into a monitor lets me log in from ANY remote device on the network. Shutdown, restart without monitor - connection refused.

Also noted, I can ssh in at any time. If I ssh in and run 'vncserver', I can then connect vncviewer headless. I take this to mean that vncserver is not starting up automatically when headless? I have followed the instructions at this page for setting up VNC server. Step 2 states, "From now on, VNC Server will start automatically whenever your Pi is powered on." I apparently am not observing this behavior.

Also related - when I am able to connect headless after ssh'ing in, if I close the connection and let the device idle for some undetermined length of time (hours), the whole process starts over again.

I'd really love some advice for this.

EDIT to add: I also tried the steps at https://www.realvnc.com/docs/raspberry-pi.html#raspberry-pi-ssh, running sudo systemctl start vncserver-x11-serviced.service and then sudo systemctl enable vncserver-x11-serviced.service This has also not had the desired effect.


4 Answers 4


I added the following lines to my config.txt file in /boot.

# NOOBS Auto-generated Settings:

This forces the headless pi to 1080p. I've seen other similar posts but this is what is working for me.

  • Much as I don't like such duct tape solutions, this one is probably the simplest one that will work. Commented Oct 10, 2016 at 9:43
  • 1
    This worked. The resolution is not quite the right size (scroll bars everywhere!), but I can sign in now after reboots without SSH. Thanks!
    – apathos
    Commented Oct 11, 2016 at 17:52

From the link you posted,

sudo systemctl enable vncserver-x11-serviced.service

This will enable the service to start when booted. It will not start the service though, you'll need to either start it or simply reboot your pi

  • I had tried that previously without effect, and tried it again just now and then rebooted. I still get a refused connection.
    – apathos
    Commented Oct 4, 2016 at 2:08
  • I followed too the link instructions and edit the config file, no success. Did you solve the problem? it's been already 6 hours to connect my pi to my mac headlessly Commented Dec 29, 2020 at 19:39

For a headless server with virtual desktop, try using vncserver-virtuald.service instead:

sudo systemctl enable vncserver-virtuald.service
sudo systemctl start vncserver-virtuald.service

Or use vncserver-x11-serviced.service and add hdmi_force_hotplug=1 to /boot/config.txt as @bigmac described to view the same desktop as presented over the HDMI output.


hdmi_force_hotplug=1 is the only thing that needs to be changed to connect headless.

sudo nano /boot/config.txt

Scroll down to find:

#uncomment if hdmi display is not detected and composite is being output.

Uncomment the hdmi_force_hotplug=1

Save on exiting nano. Shut down the Raspberry Pi. Remove video line. Start Raspberry Pi back.

You can now connect using VNC to a headless Raspberry Pi.

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.