Software & AppsOperating SystemLinux

Why is my VNC Server Port Closed on Ubuntu 20.04?

Ubuntu 20

When using the TigerVNC server on Ubuntu 20.04, you might encounter an issue where you’re unable to connect because port 5901 is closed. This issue can persist even after allowing port 5901/tcp in the firewall and disabling the firewall. In this article, we will delve into the possible reasons behind this issue and provide detailed solutions to troubleshoot it.

Quick Answer

The VNC server port may be closed on Ubuntu 20.04 due to incorrect VNC server configuration, the server not running, incorrect IP address binding, a closed port, incorrect network configuration, or the server not being started. By double-checking the VNC server configuration, verifying the server status, checking the IP address binding, verifying the port status, checking the network configuration, and ensuring the server is started, you can troubleshoot and resolve the issue.

VNC Server Configuration

The first step in troubleshooting is to double-check the VNC server configuration. Ensure that the TigerVNC server is set up to listen on all network interfaces, not just the loopback interface.

You can achieve this by adding -localhost no to the command line when starting the server. Alternatively, you can modify the /etc/vnc.conf file to set $localhost = "no";.

The -localhost no parameter instructs the VNC server to listen on all network interfaces, not just the loopback interface.

Verify the VNC Server Status

Next, verify if the VNC server is running. You can do this by using the command systemctl status vncserver@:1 or service vncserver@:1 status.

The systemctl status command checks the status of a service. The vncserver@:1 parameter specifies the VNC server service. The output should indicate that the service is active and running without any errors.

Check the IP Address Binding

Another important step is to check if the VNC server is binding to the correct IP address. Use the command netstat -tuln | grep 5901 to see if the VNC server is binding to the correct IP address.

The netstat -tuln command displays network connections, listening ports, and the program associated with them. The grep 5901 parameter filters the output to show only lines containing “5901”. The server should be binding to the server’s IP address, not just the loopback address (127.0.0.1).

Verify the Port Status

Next, verify that the port is open. Run the command nmap localhost to check if port 5901 is open on the server itself.

The nmap command is a network scanning tool. The localhost parameter specifies the local machine. If port 5901 shows as closed, there might be an issue with the VNC server configuration or the server’s firewall settings.

Check the Network Configuration

If you are trying to connect to the VNC server from another device on the LAN, check the network configuration. Run the command nmap <server_ip> from that device to check if port 5901 is open.

If it shows as closed, there might be a network configuration issue or a firewall blocking the connection.

Ensure the VNC Server is Started

Finally, ensure that the VNC server is started. VNC servers are not daemons by default, so you need to manually start the server. Make sure that you have started the VNC server using the appropriate command or service.

If none of the above steps resolve the issue, you may need to provide more information about your setup, such as the specific VNC server version, any error messages you encounter, and the output of commands like netstat or iptables.

In conclusion, a closed VNC server port on Ubuntu 20.04 can be caused by various issues, including incorrect VNC server configuration, the server not running, incorrect IP address binding, a closed port, incorrect network configuration, or the server not being started. By following the steps outlined in this article, you should be able to identify and resolve the issue.

How do I check if the VNC server is running on Ubuntu 20.04?

You can check the status of the VNC server by using the command systemctl status vncserver@:1 or service vncserver@:1 status.

How can I modify the VNC server configuration to listen on all network interfaces?

To configure the VNC server to listen on all network interfaces, you can add -localhost no to the command line when starting the server or modify the /etc/vnc.conf file to set $localhost = "no";.

How do I check if the VNC server is binding to the correct IP address?

You can use the command netstat -tuln | grep 5901 to check if the VNC server is binding to the correct IP address. The server should be binding to the server’s IP address, not just the loopback address (127.0.0.1).

How can I verify if port 5901 is open on the VNC server itself?

You can run the command nmap localhost to check if port 5901 is open on the VNC server itself. If the port shows as closed, there might be an issue with the VNC server configuration or the server’s firewall settings.

How can I check if port 5901 is open on another device on the LAN?

To check if port 5901 is open on another device on the LAN, you can run the command nmap <server_ip> from that device. If the port shows as closed, there might be a network configuration issue or a firewall blocking the connection.

How do I start the VNC server on Ubuntu 20.04?

VNC servers are not daemons by default, so you need to manually start the server. Make sure that you have started the VNC server using the appropriate command or service.

Leave a Comment

Your email address will not be published. Required fields are marked *