If you’ve tried to connect to your server and been met with ssh: connect to host X port 22: Connection refused, you’re not alone. This is one of the most common VPS access issues, and in most cases, it’s quick to diagnose and fix once you know where to look.
This guide walks through the exact causes behind an SSH connection refused error and how to resolve each one, step by step.

What “Connection Refused” Actually Means
It’s important to understand what this error is telling you, because it rules out several possibilities right away.
A “connection refused” message means your request reached the server, but nothing was listening on the port you tried to connect to. This is different from a connection timeout, which usually points to a network or firewall issue where your request never reached the server at all.
In short: the server responded, but actively rejected the connection. That narrows the problem down to a handful of likely causes on the server itself.
Common Causes of SSH Connection Refused
Before jumping into fixes, it helps to know what typically causes this error:
- The SSH service (sshd) isn’t running
- SSH is listening on a different port than you’re connecting to
- The server recently rebooted and SSH didn’t start automatically
- A firewall or security group is blocking port 22 internally
- SSH configuration file has an error preventing the service from starting
- The VPS itself is experiencing resource exhaustion. On instances with extremely low available memory, sshd may fail to start or be terminated by the operating system before it can bind to the port.
Each of these has a specific fix, which we’ll cover below.
How to Diagnose the Problem
Step 1: Confirm the Server Is Actually Reachable
Start by pinging the server:
ping your-server-ip
If you get replies, the server is online and network-reachable. If you get no response, this may not be an SSH issue at all, it could be a broader connectivity problem. In that case, check with your hosting provider before troubleshooting SSH further.
Step 2: Test the SSH Port Directly
A ping only confirms the server is online, it doesn’t tell you anything about port 22 specifically. To check whether the port itself is refusing connections, run:
nc -zv your-server-ip 22
If nc isn’t available, telnet works just as well for this test:
telnet your-server-ip 22
A response like “Connection refused” confirms the issue is isolated to SSH rather than a broader network problem, which tells you it’s time to move on to the console.
Step 3: Access the Server Through Your Provider’s Console
Since SSH isn’t working, you’ll need another way in. Most VPS providers, including CreativeON, offer a browser-based console (sometimes called VNC or a serial console) accessible from the control panel. This lets you log in locally without relying on SSH.
Use this console for every step below.
Step 4: Check If the SSH Service Is Running
Once logged in through the console, check the status of the SSH daemon:
systemctl status sshd
On some distributions, the service may be named ssh instead of sshd:
systemctl status ssh
If the output shows inactive or failed, that’s your answer, the service isn’t running, so there’s nothing listening on port 22.
Step 5: Check the System Logs for the Exact Failure
If the service status doesn’t tell you enough, the logs usually will. Check the SSH service log directly:
journalctl -u sshd
Or review the broader system log for recent errors:
journalctl -xe
These logs will often point to the exact reason sshd failed to start, whether it’s a configuration error, a permissions issue, or the service being killed due to low memory. This is usually the fastest way to identify the root cause before applying a fix.
Fixing SSH Connection Refused
Fix 1: Start or Restart the SSH Service
If the service is stopped, start it:
systemctl start sshd
Then enable it so it starts automatically on future reboots:
systemctl enable sshd
If the service is running but connections are still refused, restart it to clear any stuck state:
systemctl restart sshd
Fix 2: Check Which Port SSH Is Listening On
If SSH has been configured to run on a non-default port (a common security practice), connecting on port 22 will always be refused. Check the configuration:
grep -i port /etc/ssh/sshd_config
If you see a custom port listed, connect using that port instead:
ssh -p [port_number] user@your-server-ip
If no port is specified in the config, SSH defaults to port 22.
Fix 3: Confirm SSH Is Listening on the Correct Interface
Use the following command to see which ports and interfaces are actively listening:
ss -tulnp | grep ssh
If SSH is only bound to 127.0.0.1 (localhost) instead of 0.0.0.0 (all interfaces), external connections will always be refused. Update the ListenAddress directive in /etc/ssh/sshd_config to 0.0.0.0, then restart the service.
Fix 4: Validate the SSH Configuration File
A syntax error in sshd_config will prevent the service from starting at all. Test the configuration before restarting:
sshd -t
If this command returns no output, the configuration is valid. If it reports an error, it will point to the exact line causing the problem, fix that line and try starting the service again.
Fix 5: Check Local Firewall Rules
Even if SSH is running correctly, a local firewall on the server can silently block the connection. Check common firewall tools:
ufw status
or
firewall-cmd –list-all
If port 22 (or your custom SSH port) isn’t allowed, add a rule to permit it. This is a server-level firewall check, separate from any network-level security groups, which deserve their own dedicated troubleshooting process.
Fix 6: Check Cloud Firewalls and Security Groups
If your VPS runs behind a cloud provider’s Security Group or Cloud Firewall, verify that SSH is allowed there as well. These rules sit outside the operating system entirely, so even if ufw or firewalld looks fine, the connection can still be blocked upstream. This is easy to overlook and is one of the most common reasons SSH stays refused even after every server-side setting checks out.
Verifying the Fix
Once you’ve applied a fix, confirm SSH is working correctly before closing the console session, this way you always have a fallback if something’s still wrong.
- Check that the service is active: systemctl status sshd
- Confirm it’s listening: ss -tulnp | grep ssh
- From your local machine, attempt to connect again:
ssh user@your-server-ip
If you’re using a custom port, don’t forget to include it in the connection command.

Preventing This Issue in the Future
A few habits go a long way toward avoiding this problem down the line:
- Enable SSH on boot so it doesn’t matter if the server restarts unexpectedly.
- Keep a console access method available at all times as a fallback.
- Test configuration changes with sshd -t before restarting the service.
- Document any custom SSH port so you don’t lock yourself out by forgetting it.
- Monitor server resources to catch issues before they cause services to fail.
If you’re looking to lock down SSH access further as a long-term security measure, our VPS Server Hardening Checklist and VPS Firewall Setup Guide cover this in more detail.
Conclusion
An SSH connection refused error is almost always a sign that the SSH service isn’t running, is misconfigured, or is being blocked locally, not a sign of a bigger network failure. By working through the service status, port configuration, and firewall rules in order, you can usually restore access within a few minutes using your provider’s console as a fallback entry point.
If you continue running into VPS access issues after trying these steps, CreativeON’s support team is available to help you get back in securely. Also, double-check that you’re connecting to the correct SSH port if you’ve customized it, this alone accounts for a surprising number of “refused” errors.
Frequently Asked Questions
This usually happens after a server reboot if SSH wasn’t set to start automatically, or after a configuration change was applied without validating it first.
No. A refused connection means the server responded but rejected it, usually because SSH isn’t running. A timeout means the request never reached the server, which points to a network or firewall issue instead.
Not reliably. If SSH itself is the problem, you need an alternate way into the server, most VPS providers offer a browser-based console for exactly this situation.
No, changing the port is a security choice, not a fix. If you already use a custom port, just make sure you’re connecting with it.
Check the configuration file for syntax errors using sshd -t. A misconfigured file is the most common reason the service fails to start.

The author
Asher Feroze
I’m Asher Feroze, and I’ve been part of CreativeON for several years, working in various roles including Manager Operations, Business Development Manager, and technical support for our web hosting services. Over time, I’ve gained deep insights into both the business and technical sides of the industry. Now, I use that experience to write informative articles for CreativeON, Gworkspace, and gworkspacepartner.pk, helping readers make smart choices when it comes to web hosting and Google Workspace solutions.
