I'm trying to access a Pi 4B+ with a dynamically-assigned IP address. I can VNC to the Pi using the (current) IP address, and I can hit it with no problem with Firefox, ssh or ping using the address raspberrypi.local, but when I try to connect to that address with VNC Viewer I get the message The connection was refused by the computer. How do I set up my Pi so I can VNC to it without editing the connection every time I reboot the Pi?

  • I can connect to mine with MilliwaysPi4.local. You need to provide more details of what you are doing and settings which don't work.
    – Milliways
    May 29, 2021 at 0:58
  • custom port perhaps?
    – Abel
    May 30, 2021 at 13:43

1 Answer 1


I figured it out. VNC supports multiple sessions, identifying each with a display number (which corresponds to a port number in the 5900+ range). I needed to include the display number in the address, like this: raspberrypi.local:1.

(You might think that default values would handle this transparently; for some reason, though, RealVNC Client defaults to display 0 while vncserver defaults to 1, and so they miss each other in the dark.)

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.