PuTTY is an open-source and free software allowing you to access a server on either a Unix or multi-user system. But as with most systems, things tend to go wrong.
If you’re suing PuTTY, you may come across the “Local Connection Refused” error. In such cases, you wouldn’t be able to connect to the server. It can be both a server or client side error.
In this article, learn how to fix the error.
Why the Error Happens?
You’d use the PuTTY client to connect to your server via SSH. When you see the “Connection Refused” error, you will get the following message:
While the SSH host is routed, the host, for whatever reasons, rejected the request. It might have been caused by several reasons. In the subsequent sections, learn about the five common reasons and how to fix them.
Likewise, some server owners switch from a default to a custom SSH port. But in the process, they fail to open the port on the server.
Solution
To fix this, you need to check if the IP address is blocked by the server firewall. Use this command for this:
Once confirmed that it’s blocked, you need to unblock it and restore connectivity.
Besides that, check the connectivity to SSH port. Use Telnet command for this purpose,
After that, check the server log to check the reason why it was blocked. If any rule mentioned in the firewall is behind this error, then you might remove the wall from firewall configuration.
For handling incoming connections, SSH service users something which is known as sshd daemon. When the service fails, PuTTY client isn’t able to establish communication with the SSH server.
Solution
The first thing you need to do is check if the SSH service is still actively listening for connection by employing the “netstat” command.
If you see that the service fails to respond, kill the existing service and restart it. If you’re on CentOS 7 servers, use this command for restarting your SSH service:
Users will see the “localhost connection refused” error if they used a wrong port to access the server.
Solution
First, you have to confirm the SSH port by using Console to access the server. Then check the SSH configuration file with path as “/etc/sshd/sshd_config”.
Inside the file, locate the “Port” parameter which lists the SSH port that the user used to access the server. Alternatively, you can use the netstat command as well to check the port.
Once you’ve identified the correct port, check the details of the SSH client. Ensure that the user reuses the correct port from now on.
Besides that, if users are using the wrong IP addresses or if there’s an address conflict, the connection will be terminated. Multiple servers using the same IP address is one of those scenarios for PuTTY misconfiguration.
Solution
To fix the configuration issue, you need to check the configuration details like IP address, username, SSH port, and connection type. Ensure that these are correct.
Next, use tools like nmap to find the servers that are running on the network. When you come across an IP conflict, change the IP address of the servers.
Solution
First you need to confirm that it’s the private key causing the connection refusal error. If so, you need to create new key pair and test the connection.
After that, look at the permission and ownership set for the key files in .ssh folder. If there are problems, you need to fix them before moving ahead. Finally, check for permission set in .ssh/authorized_keys file since that’s where public key is stored.
So the above five reasons can result in localhost connection refused error. Try one by one to find out the exact cause and fix them accordingly. For further assistance, get in touch with your hosting provider.
If you’re suing PuTTY, you may come across the “Local Connection Refused” error. In such cases, you wouldn’t be able to connect to the server. It can be both a server or client side error.
In this article, learn how to fix the error.
Why the Error Happens?
You’d use the PuTTY client to connect to your server via SSH. When you see the “Connection Refused” error, you will get the following message:
Code:
Putty Fatal Error
Network Error: Connection Refused
- Firewall restrictions
Likewise, some server owners switch from a default to a custom SSH port. But in the process, they fail to open the port on the server.
Solution
To fix this, you need to check if the IP address is blocked by the server firewall. Use this command for this:
Code:
iptables -nL
Besides that, check the connectivity to SSH port. Use Telnet command for this purpose,
Code:
telnet xx.xx.xx.xx 22
- Service Downtime
For handling incoming connections, SSH service users something which is known as sshd daemon. When the service fails, PuTTY client isn’t able to establish communication with the SSH server.
Solution
The first thing you need to do is check if the SSH service is still actively listening for connection by employing the “netstat” command.
If you see that the service fails to respond, kill the existing service and restart it. If you’re on CentOS 7 servers, use this command for restarting your SSH service:
Code:
systemctl restart sshd
- You’ve Moved to a Custom SSH Port
Users will see the “localhost connection refused” error if they used a wrong port to access the server.
Solution
First, you have to confirm the SSH port by using Console to access the server. Then check the SSH configuration file with path as “/etc/sshd/sshd_config”.
Inside the file, locate the “Port” parameter which lists the SSH port that the user used to access the server. Alternatively, you can use the netstat command as well to check the port.
Once you’ve identified the correct port, check the details of the SSH client. Ensure that the user reuses the correct port from now on.
- Wrong PuTTY Configuration
Besides that, if users are using the wrong IP addresses or if there’s an address conflict, the connection will be terminated. Multiple servers using the same IP address is one of those scenarios for PuTTY misconfiguration.
Solution
To fix the configuration issue, you need to check the configuration details like IP address, username, SSH port, and connection type. Ensure that these are correct.
Next, use tools like nmap to find the servers that are running on the network. When you come across an IP conflict, change the IP address of the servers.
- Invalid SSH Key
Solution
First you need to confirm that it’s the private key causing the connection refusal error. If so, you need to create new key pair and test the connection.
After that, look at the permission and ownership set for the key files in .ssh folder. If there are problems, you need to fix them before moving ahead. Finally, check for permission set in .ssh/authorized_keys file since that’s where public key is stored.
So the above five reasons can result in localhost connection refused error. Try one by one to find out the exact cause and fix them accordingly. For further assistance, get in touch with your hosting provider.