Software⏱️ 3 min read📅 2026-06-11

How to Fix: vnc viewer error: unable connect to socket: Connection refused (111)

Troubleshooting VNC connection issues on Linux server.

Quick Answer: Check the firewall settings and ensure that the vncserver service is running correctly. You can also try increasing the port number in the /etc/sysconfig/vncserver file to resolve the Connection refused error.

The error 'Connection refused (111)' in VNC Viewer indicates that the VNC server is not listening on the specified port. This error affects users who are trying to connect to a remote VNC server using the VNC Viewer application.

This issue can be frustrating for remote workers or administrators who rely on VNC for access to their servers. In this guide, we will walk you through the steps to resolve this error and establish a stable connection.

🛑 Root Causes of the Error

  • The first main reason why this error happens is that the VNC server is not configured to listen on the specified port. This can occur if the 'listen' option in the /etc/sysconfig/vncserver configuration file is set to a value other than 'tcp'. Additionally, the firewall rules may be blocking the connection.
  • Another alternative reason for this error is that the VNC server process has crashed or terminated unexpectedly, preventing it from listening on the specified port.

🚀 How to Resolve This Issue

Check and modify the VNC server configuration file

  1. Step 1: Open the /etc/sysconfig/vncserver configuration file in a text editor using the command 'sudo nano /etc/sysconfig/vncserver'.
  2. Step 2: Locate the line that specifies the listening option ('listen') and change its value to 'tcp' or remove any other options. For example, if the current line is '-listen tcp -localhost', change it to '-listen tcp'.
  3. Step 3: Save and close the file. Then, restart the VNC server service using the command 'sudo service vncserver restart'.

Check firewall rules and VNC server process status

  1. Step 1: Verify that the firewall rules are not blocking the connection by checking the iptables configuration file using the command 'sudo grep -v 'DROP' /etc/sysconfig/iptables'. If the output shows any lines starting with 'ACCEPT', remove them. Otherwise, add a new rule to allow incoming connections on the specified port.
  2. Step 2: Check if the VNC server process is running and listening on the specified port using the command 'netstat -tlnp | grep vncserver'. If the process is not found or not listening on the specified port, restart the VNC server service.

💡 Conclusion

To establish a stable connection to your remote VNC server, it is essential to resolve this error by checking and modifying the VNC server configuration file, verifying firewall rules, and ensuring that the VNC server process is running correctly. By following these steps, you should be able to connect to your VNC server without encountering the 'Connection refused (111)' error.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions