How to Fix the SSH “Connection Refused” Error
Last modified: January 10, 2021
Secure Shell (SSH) is one of the key WordPress development tools. It allows users to access to platforms and software that make it easier to create custom coding and complete other tasks more efficiently.
If you’re attempting to use SSH and see a ‘Connection Refused’ error, then you may be concerned. However, this is a common issue and it is really easy to fix without the need of a developer or website designer.
Ways to Fix Your SSH Error
Here are some of the solutions to fix your SSH error.
Check Your SSH Service
The first thing you need to check is that your SSH daemon is running. If this is not running, then you’re going to get an error and this could be the problem.
There are numerous reasons why the daemon could be offline. It could have a high level of traffic, resource outages or even a DDoS attack. You might need to speak to the provider to ensure they know of the problem and they’re trying to fix it.
If you suspect the at the SSH Daemon is down, you can also try entering this command line:
sudo service ssh status
If the command line returns a status of down, then you’re sure.
Check your Credentials
Another thing that you need to check your credentials when logging into your system. There are four key pieces of information that need to be correct to run SSH that includes:
Host name – This is the IP address of the server you’re trying to connect to.
Username – Your SFTP username.
Password – The password for your SFTP username.
Port – The default for a port is usually 22. But some suppliers will change this. So check with the provider.
Be sure there are no typos or incorrect entered information. This might solve the problem quickly.
The Port You’re Using is Closed
A port is a simple term for the endpoint to which you’re trying to connect to on a server. You have to make sure that you have the correct port name and also that the port is open, or available to be used.
Any port has a security risk. Hackers can try to exploit them and then gain access to the server. Sometimes ports are closed to prevent them from becoming infected or infiltrated. You can check whether your port has been closed by running this command:
sudo lsof -i -n -P | grep LISTEN
This should return a list of the ports available that have a listen state. Ideally, you will see your port listed. If not, then you will need to reopen the port again to use it.
SSH isn’t Installed
If you’re using SSH for the first time, you might think its been installed when it hasn’t. Most providers do have SSH daemons installed on the servers by default, so this error is less likely, but it is a good idea to check anyway.
Firewall Settings Prevent SSH
Since open ports present a security risk for your computer or server, some firewalls installed will protect the server by blocking the SSH connection. You can view your firewall’s rules to check for this by using the following commands
sudo iptables-save # display IPv4 rules sudo ip6tables-save # display IPv6 rules
All results will be different. But you should look for elements within the results that will tell you if the firewall is blocking the SSH connection.
Final Word: How to Fix the SSH “Connection Refused” Error
There are some simple fixes that allow you to solve the SSH connection refused error. Take a look above and try them out, to see if you can reuse SSH again.
A Savvy WordPress developer, years of experience developing for web (PHP, JS, jQuery, Vue, MySQL, etc.), SEO specialist, and more…