Secure Shell (SSH) is a key WordPress evolution tool. It grants avant-garde users admission to fundamental platforms and software that brand coding and other tasks easier, faster, and more organized.

Then if you effort to use SSH merely to run into a "Connection refused" error, you may start to feel concerned. Still, this is a common issue, and information technology's entirely possible to fix it on your ain with just a bit of troubleshooting. Yous'll exist dorsum to running commands in no time flat.

In this mail, we'll talk over what SSH is and when to employ it. Then we'll explicate some common reasons your connection may be refused, including in PuTTY. Finally, nosotros'll provide some troubleshooting tips.

Let's dive in!

Prefer to watch the video version?

What Is SSH and When Should I Use Information technology?

Secure Shell (SSH), as well sometimes called Secure Socket Vanquish, is a protocol for securely accessing your site's server over an unsecured network. In other words, it's a way to safely log in to your server remotely using your preferred command-line interface:

ssh login example
Using SSH to remotely access a WordPress site hosted on Kinsta

Unlike File Transfer Protocol (FTP), which only enables you to upload, delete, and edit files on your server, SSH tin accomplish a wide range of tasks. For instance, if an error locks y'all out of your WordPress site, you can use SSH to access it remotely.

This protocol also enables y'all to use several fundamental developer tools, including:

  • WP-CLI. The WordPress command line. You tin can employ it for a diversity of tasks, including new installations, majority plugin updates, and media file imports.
  • Composer. A PHP package director. Information technology enables you to implement several frameworks for use in your site's code by pulling the necessary libraries and dependencies.
  • Git. A version control system used to track changes in code. This is peculiarly useful for teams of developers working together on a single project.
  • npm. A JavaScript package director. Information technology includes a command-line and JavaScript software registry. Notation: Kinsta customers will demand an Enterprise plan in social club to admission this feature.

It's important to note that using SSH is an advanced skill. Mostly speaking, lay users of WordPress should contact their developers or hosting providers for help, rather than trying to resolve bug with SSH themselves.

Why Is My SSH Connection Refused? (5 Reasons for Connectivity Errors)

Unfortunately, there are many scenarios that could occur while you're trying to connect to your server via SSH, which might result in an error reading "Connection refused".

Below are some of the most mutual issues that might be causing problems for you lot.

1. Your SSH Service Is Down

In lodge to connect to your server with SSH, it must be running an SSH daemon – a program that runs in the groundwork to listen for and take connections.

If this service is down, you will not be able to successfully connect to your server and may receive a Connection refused error:

connection refused error
Connectedness Refused error in Concluding

Your server's SSH daemon may be down for a wide multifariousness of reasons, including unexpected traffic spikes, resource outages, or even a Distributed Deprival of Service (DDoS) attack. In addition to the troubleshooting steps nosotros'll mention below, you may want to contact your hosting provider to determine the root cause of the result.

If you suspect that your SSH service might be down, you can run this control to find out:

          sudo service ssh condition        

If the command line returns a status of down, then you've probable found the reason behind your connectivity error.

2. You Take the Incorrect Credentials

Although information technology may seem besides simple to exist true, it's possible that you're simply entering the wrong credentials when trying to connect to your server. There are four pieces of information needed to run SSH:

  • Host name. The IP address of the server y'all're trying to connect to or your domain name.
  • Username. Your (Due south)FTP username.
  • Password. Your (S)FTP password.
  • Port. The default port is 22. However, some hosting providers (including Kinsta) modify their SSH port number for security reasons. If this is the case, you lot should exist able to observe information technology by logging in to your MyKinsta dashboard.

Yous can also check to encounter which port is being used for SSH by running this control:

          grep Port /etc/ssh/sshd_config        

The control line should return the right port.

Subscribe Now

Bank check to make sure you're entering the correct credentials and taking into business relationship the possibility of typos or entering the wrong IP address or port.

3. The Port You're Trying to Apply Is Closed

A "port" is simply the endpoint to which yous're directed when connecting to your server. In addition to making certain you have the right one, you'll also want to check to see if the port you're trying to apply is open.

Any open port is a security vulnerability, as hackers can try to exploit information technology and gain access to the server. For this reason, unused ports are ofttimes closed to prevent attacks.

In the event that port 22, or the custom SSH port for your server, has been closed, you will likely meet a Connection refused fault. You tin can come across all the ports listening on your server past running this control:

          sudo lsof -i -n -P | grep LISTEN        

This command should render a list of ports with the Listen country. Ideally, you desire to see port 22 or your server's custom SSH port listed here. If information technology'due south not, you'll need to reopen the port in gild to connect to your server.

iv. SSH Isn't Installed on Your Server

As we briefly mentioned earlier, servers use SSH daemons to heed for and accept connections. Therefore, if the server you lot're trying to connect to doesn't have 1 installed, yous won't be able to access information technology using SSH.

Generally speaking, virtually all hosting providers volition have SSH daemons installed on their servers by default. This item effect is more common on localhost or defended servers.

v. Firewall Settings Are Preventing an SSH Connectedness

Since open ports nowadays a security risk, firewalls installed to protect servers from hackers sometimes block connections to them. Unfortunately, this means that even harmless users who are trying to SSH into their servers may receive a Connexion refused mistake as a consequence of firewall settings.

If your setup appears to be in club and yous notwithstanding can't connect, have a wait at your firewall's rules. Y'all tin display them in your command-line interface with the following commands:

          sudo iptables-save # display IPv4 rules        
          sudo ip6tables-save # brandish IPv6 rules        

Your results will vary, but you lot'll want to await for these elements to determine if your firewall is blocking SSH connections:

  • dport 22: This refers to the destination port, which for SSH is usually port 22 (reminder: Kinsta doesn't use this port number).
  • Pass up: This would indicate that connections are existence refused from the specified destination.
  • DROP: Similar REJECT, this means that connections to the relevant port are being blocked.

If yous search the results of the commands in a higher place for dport 22, you should be able to determine if your firewall is preventing an SSH connection. If so, yous'll accept to modify the rules to accept requests.

Why Does PuTTY Say Connexion Refused?

PuTTY is an SSH client. If you're familiar with FTP, this platform is the FileZilla equivalent to SSH on Windows machines. In other words, PuTTY enables users to input their credentials and launch an SSH connectedness:

download putty
The PuTTY website

If y'all're a PuTTY user and encounter the Connection refused error, the cause is likely 1 of those listed above.

This is an SSH connectivity error like any other, and the troubleshooting tips beneath should work whether you're using PuTTY, Terminal, or whatsoever other plan for connecting to your server with SSH.

We've taken our cognition of effective website direction at scale, and turned it into an ebook and video course. Click hither to download the The 2020 Guide to Managing 40+ WordPress Sites!

How Exercise I Troubleshoot SSH Connectivity Errors?

When you're experiencing an SSH connectivity error, there are a few steps yous can take to troubleshoot it depending on the crusade. Here are some tips for troubleshooting the reasons for a Connection refused error that we covered above:

  • If your SSH service is down. Contact your hosting provider to see why your SSH service isn't running. For localhost or dedicated servers, you can utilize the command sudo service ssh restart to try to become it running once more.
  • If yous entered the wrong credentials. Once you've double-checked the SSH port using the grep Port /etc/ssh/sshd_config command, try connecting again with the correct details.
  • If your SSH port is airtight. This is usually a side result of one of the two reasons listed below. Either install an SSH daemon on the server you desire to connect to or change your firewall rules to accept connections to your SSH port.
  • If SSH isn't installed on your server. Install an SSH tool such as OpenSSH on the server yous want to connect to using the sudo apt install openssh-server command.
  • If your firewall is blocking your SSH connection. Disable the firewall rules blocking your SSH connectedness past changing the destination port's settings to Take.

If you're attempting to connect to your hosting provider'due south server, it may be wiser to contact support than to try troubleshooting the problem yourself. Users on localhost or dedicated servers may be able to find further support on more advanced forums if none of the above solutions works.

Are you getting the 'Connectedness refused' mistake over SSH? Learn why that's happening and how to troubleshoot SSH connectivity errors thanks to this guide đź™… ✋ Click to Tweet

Summary

Being able to connect to your server with SSH is convenient in a wide range of situations. It can enable you to admission your site when y'all're locked out of your WordPress dashboard, run commands via WP-CLI, track changes in your site's code with Git, and more.

Although there are several causes that could exist behind your SSH connectivity error, these are a few of the most common:

  1. Your SSH service is down.
  2. Y'all take the wrong credentials.
  3. The port you're trying to use is closed.
  4. SSH isn't installed on your server.
  5. Firewall settings are preventing an SSH connection.

Save time, costs and maximize site performance with:

  • Instant assistance from WordPress hosting experts, 24/7.
  • Cloudflare Enterprise integration.
  • Global audition achieve with 32 data centers worldwide.
  • Optimization with our built-in Application Performance Monitoring.

All of that and much more than, in one plan with no long-term contracts, assisted migrations, and a 30-solar day-money-back-guarantee. Cheque out our plans or talk to sales to find the plan that's right for you.