Raspberry Pi VNC fail connection
Asked Answered
A

6

7

I face a problem that I can ping to correct IP address, it have no loss. And also I use nmap ping the pi address, and I get it correctly. Then I using VNC viewer to try access to pi, but it always show up "The connection was refused by the host computer"

Did u all have any idea ?

Aimo answered 2/3, 2017 at 7:33 Comment(2)
I had this issue once, it was LightDM not starting.Passbook
"And also I use nmap" Do you have ssh access? You should not scan your own server via hacker tool :) You can use lsof -Pni | egrep "(UDP|LISTEN)" and get all the bound network ports momentally!Meatball
G
15

Your problem indicates that your Raspberry Pi was reached by the connection attempt, but that no service was running on the relevant port and hence the connection was refused. I think, this is because the VNC service is not running on your Raspberry Pi.

Update 1
Raspbian now comes with the server by default thanks to a partnership with RealVNC, it just needs to be enabled.

Original
You must enable VNC Server on your Raspberry Pi using terminal

sudo apt-get update
sudo apt-get install realvnc-vnc-server

or you can also enable VNC Server on the command line using the sudo raspi-config command.

Advanced Options->VNC:Yes

Now you can connect to the VNC Server using a application such as VNC Viewer.

Gusgusba answered 2/3, 2017 at 12:4 Comment(2)
after install you need to run the VNCServer to make the connection from the other machineLightsome
When VNC is not found in advanced, try to enable it using terminal: sudo systemctl enable vncserver-x11-serviced.service and reboot the deviceChapin
S
9

I have been having this issue with my Raspberry Pi Zero W even though it worked perfectly beforehand. This page https://www.realvnc.com/en/connect/docs/raspberry-pi.html should help.

I ran vncserver in a ssh window after verifying the interface settings in raspi-config. It started the VNC Server and gave me the VNC Server catchphrase and the IP address with Port Number as shown in the photo linked below.

vncserver output

After running that command I was able to get the VNC Viewer on my windows machine to connect to the pi.

I then ran sudo systemctl enable vncserver-x11-serviced.service in the ssh window so that it would start automatically on subsequent reboots.

Squawk answered 5/6, 2019 at 2:9 Comment(0)
W
3

For people using newer version of Raspberry, VNC option is found under:

Config>Interface Options enter image description here

Wallie answered 27/9, 2022 at 16:37 Comment(0)
R
2

I've had this same problem but found a different reason. I found three ways to get around this error message.

  1. Plug a mouse or keyboard into the Raspberry Pi zero, waking up the screen and the VNC connection.
  2. Wait about 5 - 10 minutes which is the amount of time for the screen saver to kick in which seems to wake up VNC connection. but don't wait to long other wise run this command to get things going via ssh "systemctl start vncserver-x11-serviced.service".

I am hoping the new update they just published will fix this problem. I don't see this as much with the Raspi B3+ as with the Zero H.

The last was plug in both monitor and mouse and that for sure fixes the VNC issues but defeats the headless connection. It seems that running headless and the screen/saver are somehow related but just not smart enough to figure it out.

Rhapsodic answered 14/4, 2019 at 18:39 Comment(0)
S
0

pinging to any service will only tells us that whether the server is currently listening on that port or not. It will not tell you the possible result to connection request asked by client.

It seems that, you have installed VNC server but not started it properly. Use this command to start it...

# vncserver start

Also recheck the port number is correct or not.

Scrubland answered 19/4, 2018 at 11:28 Comment(0)
D
0

With the Rasp Pi 4 - had connecting fail after rebooting both the server and client (both Rasp Pi 4s). Took a while to realize that I have two clients: One named "VNC Client", the other "VNC Viewer for Google Chrome". The former works, the latter doesn't.

Dichasium answered 3/3, 2020 at 19:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.