A Complete Guide to Solving the Local Connection Refused Error in PuTTY Client

A Complete Guide to Solving the Local Connection Refused Error in PuTTY Client

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.

putty1.jpg

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
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.
  • Firewall restrictions
If there’s a firewall that is protection the connection, then it may interfere with the connection. The firewall might be blocking certain IP addresses or SSH ports. The main reason is because of abnormal behavior that firewall determines is spamming.

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
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,

Code:
telnet xx.xx.xx.xx 22
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.
  • Service Downtime
When there’s a broken SSH server or the SSH service is not running, you’ll see a downtime and this will throw the local connection refused error.

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
Standard SSH ports are more likely to be attacked and hacked. To make things harder for hackers, server owners allow custom ports.

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
PuTTY misconfiguration are also a common reason for the local connection refusal error. Incorrect IP addresses, host, SSH ports, improper parameters can all block the connection.

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
Key-based authentication usually are more secure than password-based authentication. But it can also throw an error if there are incorrect permission set for the SSH key pair. An incorrect private key will block the users immediately.

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.
Author
kumkumsharma
Views
9,472
First release
Last update
Rating
0.00 star(s) 0 ratings

More resources from kumkumsharma

Top