Jackdon Chew
Jackdon Chew

Reputation: 135

Raspberry Pi VNC fail connection

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 ?

Upvotes: 7

Views: 54414

Answers (6)

Dash
Dash

Reputation: 834

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

Config>Interface Options enter image description here

Upvotes: 3

rdl
rdl

Reputation: 1

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.

Upvotes: 0

Matt Baker
Matt Baker

Reputation: 91

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.

Upvotes: 9

Dale W ETCHELLS
Dale W ETCHELLS

Reputation: 21

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.

Upvotes: 2

avatli
avatli

Reputation: 630

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.

Upvotes: 15

KVaibhav
KVaibhav

Reputation: 1

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.

Upvotes: 0

Related Questions