I had VNC working great -- allowing access from both my Mac and my Windows laptop. I set it up from "Sharing" under the System Settings.

This morning nothing will connect.

The only thing that has changed on Ubuntu is that I was working to get the Mosquitto MQTT server running, and as part of that I enabled ufw so I could open port 1883. I was connected via VNC from both of my devices (i.e. Mac and Window 10 laptop) -- in fact I issued the ufw commands from the Windows 10 laptop VCN'd into the Ubuntu computer)

This morning is when nothing is connected or will allow connection. I'm not sure, does ufw need to have a VNC port added if it is running? If so, how do I determine which one to open?

Here is the output from ufw Status:

ufw Screenshot

  • 1
    Do you mean you had ufw disabled before? What's the output of 'sudo ufw status'? – fregger Feb 26 at 17:05
  • @fregger: It seems that ufw was disabled by default. – MarkJoel60 Feb 26 at 19:03
  • @fregger I can't post images yet, but I added a screenshot of the ufw status – MarkJoel60 Feb 26 at 19:10
  • 1
    There is no need to post terminal output as an image. edit your question and paste the text in. – Organic Marble Feb 26 at 19:24
  • Your screenshot tells us that you're blocking all ports except 1883. Assuming VNC uses the default port 5900, you need to open that port with 'sudo ufw allow 5900'. If VNC uses another port, you need to open that one. See also askubuntu.com/questions/8402/… and help.ubuntu.com/community/UFW – fregger Feb 26 at 19:51

VNC uses port 5900 by default.

VNC by default uses TCP port 5900+N, where N is the display number (usually :0 for a physical display). source

If you block that with ufw (the default) you won't be able to connect.

  • 1
    I'lll mark this as the correct answer since it was first. But everyone basically nailed it. 'sudo ufw allow 5900' was the answer. Thanks! – MarkJoel60 Feb 26 at 21:51
  • Glad you got it sorted. – Organic Marble Feb 26 at 21:55

You would be able to find more help on UFW here: Official guide to UFW

Please check out this official guide to have a better understanding of UFW and its commands. If still the issue persists, then I would request you to check your VNC setup once.

I corrupted my VNC configuration once and it took me days to identify it. To reconfigure my VNC setup, I took the help of these two guides:

Install and Configure VNC on Ubuntu 18.04 and, Installing VNC Server on Ubuntu OS

Sometimes, even the Firewall can be responsible for such errors. So, if you observe that the firewall is causing the issue. This guide highlighting Steps to Configure Firewall with UFW is your one-stop solution.

Thank you!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.