How to Fix: vnc viewer error: unable connect to socket: Connection refused (111)
Troubleshooting VNC connection issues on Linux server.
📋 Table of Contents
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
- Step 1: Open the /etc/sysconfig/vncserver configuration file in a text editor using the command 'sudo nano /etc/sysconfig/vncserver'.
- 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'.
- 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
- 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.
- 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.
❓ Frequently Asked Questions
🛠️ Related Fixes
How to Fix: Pc crashes shortly after launching game (rainbow
Fix Pc crashes shortly after launching game (rainbow six siege). Compl
How to Fix: Installing an APK on a locked down phone
Installing an APK on a locked down phone: Try using a rooted device, e
How to Fix: New PC build- no signal and no clue
Fix New PC build- no signal and no clue. Complete troubleshooting guid