How to Fix: Conection refused error for telnet and ssh
Connection refused error for telnet and ssh on Ubuntu systems.
📋 Table of Contents
The 'Connection refused' error occurs when the remote host (172.16.xx.z or localhost) is not listening on the specified port (22 for SSH and default for Telnet). This issue affects users who are trying to establish a connection with one of their systems using Telnet or SSH.
This error can be frustrating, especially if you're unable to access a system remotely. In this troubleshooting guide, we'll help you identify the root cause of the issue and provide two primary fix methods to resolve the problem.
🛑 Root Causes of the Error
- The first main reason why this error happens is that the remote host (172.16.xx.z or localhost) is not running a server process that listens on the specified port (22 for SSH and default for Telnet). This can be due to various reasons such as the system being shut down, the service being disabled, or the firewall blocking the connection.
- An alternative reason could be that the remote host is listening on a different port than what you're trying to connect to. For example, if you're trying to SSH into a system using the default port 22, but it's actually listening on port 2222, your connection will fail.
✅ Best Solutions to Fix It
Check and restart the service
- Step 1: Open a terminal on the remote host (172.16.xx.z) and check if any service is running that listens on the specified port.
- Step 2: Use the command `netstat -an` or `ss -a` to check which processes are listening on port 22 (for SSH) or the default port (for Telnet). If you find a process listening on the correct port, make a note of it. If not, proceed to the next step.
- Step 3: Restart the service that's supposed to be running on the specified port. For example, if you're trying to connect to a SSH server, restart the sshd service using `sudo systemctl restart sshd` or `sudo service ssh restart`. This will ensure that the service is restarted and listening on the correct port.
Check firewall rules
- Step 1: Open a terminal on the local machine (172.16.xx.y) and check if there are any firewall rules blocking the connection.
- Step 2: Use the command `ufw status` or `firewalld -list-all` to check the current firewall rules. If you find that there's a rule blocking the connection, remove it using `sudo ufw delete
` (for Ubuntu) or `sudo firewalld --delete-port ` (for Fedora). - Step 3: If you're still having issues after removing the firewall rule, proceed to the next step.
💡 Conclusion
To resolve the 'Connection refused' error for Telnet and SSH, first check if the remote host is running a server process that listens on the specified port. If not, restart the service or check your firewall rules to ensure they're allowing the connection. By following these steps, you should be able to establish a successful connection with your system using Telnet or SSH.
❓ 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