-2

So, I was following this guide https://linuxize.com/post/how-to-install-and-configure-vnc-on-centos-7/ on how to setup a vnc server and I'm at the part where I have to connect to my vnc server via ssh and I'm getting an error.

Error:

bind: Address already in use

channel_setup_fwd_listener_tcpip: cannot listen to port: 5901

Could not request local forwarding.

netStat of connections

4
  • Please include all essential parts of the guide you used. We encourage users not to source external links as a general rule. Thank you Commented Jan 27, 2024 at 9:32
  • Do you get this error when trying to setup the ssh tunnel like in the tutorial? Commented Jan 27, 2024 at 9:50
  • @GChuf, I tried vnc viewer on another machine also, I tried ssh -L 5901:127.0.0.1:5901 -N -f -l username server_ip_address this command from another machine. And still get this error. Commented Jan 27, 2024 at 15:36
  • 1
    The port 5901 is already listening on the machine you're trying to setup ssh tunnel on. I've updated the answer if you want to try to use another port ... meaning you're probably running vnc server on that machine already. Try the suggestion in my updated answer, but you never answered if VNC connection works without the ssh tunnel. Commented Jan 27, 2024 at 18:43

1 Answer 1

0

If you're getting this error while trying to set up thessh tunnel, it's probably because you're setting up the tunnel on the machine running VNC instead of another machine (where the VNC client is).

The error basicaly means that the port 5901 is already in use on the machine you're trying to setup a tunnel. You can try changing the port, for example to port 5902, like this:

ssh -L 5902:127.0.0.1:5901 -N -f -l username serverIP

You can try to connect to VNC without the tunnel as well, to test if your configuration works.

2
  • I did added a rule to my firewalld sudo firewall-cmd --zone=public --add-port=5901/tcp --permanent and disabled selinux and it worked thanks! Commented Jan 27, 2024 at 20:55
  • Even though the error wasnt because of the port being used, I hope my answer helped ... If it did, consider upvoting it Commented Jan 27, 2024 at 21:56

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.