PuTTY connection refused troubleshooting

You’ve done it a hundred times. Open PuTTY, punch in the IP address or hostname, hit enter, and… nothing. Or, worse, a stark, unwelcome message: “PuTTY Fatal Error: Connection refused.” It’s a common, infuriating roadblock for anyone working with remote servers, from seasoned sysadmins to developers deploying their latest code. That dreaded “PuTTY connection refused” error isn’t just a nuisance; it often signals a fundamental disconnect that needs immediate attention. But what exactly is happening under the hood when your connection gets the cold shoulder, and how do you systematically diagnose and fix it?
This isn’t just about a single setting; it’s a cascade of potential issues, each demanding a different approach. Think of it like trying to start a car that won’t turn over. Is it the battery? The starter? No fuel? You wouldn’t just keep cranking the ignition. Similarly, understanding the layers involved in an SSH connection is crucial for effective troubleshooting. We’re going to dig into the most common culprits behind a “PuTTY connection refused” message, offering clear, actionable steps to get you back in business. We’ll explore everything from network basics to server-side configurations, ensuring you have a comprehensive toolkit for resolving this persistent problem.
The Fundamental Handshake: How SSH Connections Work
Before we can troubleshoot why a PuTTY connection refused, it helps to understand what’s supposed to happen. When you initiate an SSH connection using PuTTY, you’re essentially asking your computer to perform a complex dance with a remote server. First, your PuTTY client attempts to establish a TCP/IP connection to the specified IP address and port (usually port 22 for SSH). This is like knocking on the server’s door. If the server is listening on that port and allows connections, it acknowledges your knock, and a TCP connection is established. This is the foundational layer.
Once the TCP connection is up, the SSH protocol layer kicks in. This involves a secure key exchange, authentication (usually with a password or SSH key), and then the establishment of an encrypted channel for communication. If any part of this initial TCP handshake fails, or if the server explicitly denies the connection at the TCP level, that’s when you’re most likely to see the “PuTTY connection refused” message. It’s the server essentially saying, “I’m here, but I’m not letting you in on this port,” or even, “I’m not even listening for knocks on that door.” This distinction is vital because it points you toward either a network issue or a server configuration problem.
The Role of TCP/IP and Ports
Every network service runs on a specific port. For SSH, the standard is port 22. When you tell PuTTY to connect to an IP address, it sends a SYN (synchronize) packet to that IP address on port 22. If a service is listening on that port, it responds with a SYN-ACK (synchronize-acknowledge) packet. Your client then replies with an ACK (acknowledge), and the three-way handshake is complete, establishing the TCP connection. If the server receives the SYN packet but has no service listening on that port, or if a firewall actively blocks the connection, it often responds with an RST (reset) packet, which PuTTY interprets as “connection refused.” Understanding this low-level interaction helps clarify why the error message appears the way it does – it’s not a generic failure, but a specific signal from the network or server.
Is the Server Even Online? The First, Obvious Check
It might sound ridiculously simple, but a surprising number of “PuTTY connection refused” errors stem from the server simply not being powered on or connected to the network. Before diving into complex configurations, take a moment for this elementary verification. Can you ping the server’s IP address? Open your command prompt (or terminal on macOS/Linux) and type ping [server_ip_address]. If you get a series of replies, great! The server is at least online and reachable at a basic network level. If you get “Request timed out” or “Destination host unreachable,” then your problem is much more fundamental than PuTTY.
A failed ping means you need to investigate the server’s physical status, its network cabling, or its network configuration. Is it plugged in? Is its network interface active? Is its IP address correctly configured? For virtual machines, is the VM running? Is its network adapter configured to bridge to the host network or use NAT correctly? Don’t dismiss this step, even if you’re confident the server should be online. Assumptions are the enemy of effective troubleshooting. Sometimes, the simplest solutions are the ones we overlook because we’re too busy looking for something complicated.
Checking Server Status and Network Connectivity
If it’s a physical server, check its power lights and network interface card (NIC) lights. Are they on and blinking? If it’s a cloud instance, log into your cloud provider’s console (AWS, Azure, Google Cloud, DigitalOcean, etc.) and verify the instance status. Is it running? Is its public IP address correct and assigned? For internal servers, ensure no recent network changes or outages have occurred. Verify that other services on the server (like a web server, if applicable) are accessible. If other services are also unreachable, it strongly suggests a network-wide issue or a server-wide outage, rather than an SSH-specific problem.
Firewalls: The Unseen Gatekeepers of Your Connection
Firewalls are often the primary culprits behind a “PuTTY connection refused” error, and they can exist at multiple layers. You could have a firewall on your local machine, a network firewall between your machine and the server, or, most commonly, a firewall directly on the remote server itself. Each of these can block the crucial port 22 (or whatever custom port you’re using for SSH), leading to the refusal. (See: Understanding Secure Shell (SSH).)
Let’s start with the server-side firewall. Most Linux distributions come with UFW (Uncomplicated Firewall) or firewalld by default. If SSH isn’t explicitly allowed through these, your connection will be blocked. For example, on a fresh Ubuntu server, you might need to run sudo ufw allow ssh or sudo ufw allow 22/tcp. On CentOS/RHEL, it might be sudo firewall-cmd --permanent --add-service=ssh followed by sudo firewall-cmd --reload. Always check the documentation for your specific Linux distribution.
External vs. Internal Firewalls
Beyond the server’s internal firewall, consider external network firewalls. Is there a hardware firewall, a router, or a security group (in cloud environments) that might be blocking port 22? Cloud providers like AWS use Security Groups, which are essentially virtual firewalls. If your EC2 instance’s security group doesn’t have an inbound rule allowing TCP traffic on port 22 from your IP address (or 0.0.0.0/0 for testing, though this is less secure), you’ll definitely see a “PuTTY connection refused.” Similarly, if you’re connecting to a server behind a corporate network, your company’s firewall might be restricting outbound SSH connections. This requires coordination with your network administrator.
Finally, don’t forget your own local machine’s firewall. While less common for outbound connections, some aggressive personal firewalls might interfere. Temporarily disabling it (just for testing, and with caution!) can rule out this possibility. Remember, firewalls are there for security, so disabling them permanently or opening ports unnecessarily is a bad practice. The goal is to allow only the necessary traffic from trusted sources.
Is SSH Running? The Server-Side Service Check
Even if the server is online and firewalls are correctly configured, you’ll still get a “PuTTY connection refused” if the SSH daemon (sshd) isn’t actually running on the server. This is a common point of failure, especially after server restarts, software updates, or manual configuration changes that might have inadvertently stopped the service.
How do you check if sshd is running? This is a bit of a Catch-22, as you can’t SSH in to check! You’ll need some out-of-band access. For virtual machines (VMs) or cloud instances, this usually means using a console or web-based terminal provided by your hosting provider (e.g., AWS EC2 Instance Connect, Google Cloud SSH browser, Hyper-V/VMware console). Once you have console access, you can use system commands to check the service status.
On most modern Linux systems using systemd, you’d run: sudo systemctl status sshd. You should see output indicating that the service is ‘active (running)’. If it’s ‘inactive (dead)’ or ‘failed,’ then you’ve found your problem. To start it, use: sudo systemctl start sshd. To ensure it starts automatically after reboots, enable it with: sudo systemctl enable sshd.
Legacy Systems and Alternative SSH Daemons
For older systems or those not using systemd, you might use sudo service ssh status or sudo /etc/init.d/ssh status. Regardless of the command, the goal is the same: confirm the SSH daemon is alive and well. If you’ve installed a non-standard SSH server or configured it to run on a different port, make sure you’re checking the correct service name and port. This step is critical because a running server with open firewalls is useless if the SSH service itself isn’t listening for connections.
Incorrect Port or IP Address: The Simple Typo Trap
This falls into the category of “Doh!” moments, but it’s astonishing how often a “PuTTY connection refused” error is simply due to a typo. Double-check the IP address or hostname you’ve entered in PuTTY. Is it correct? Is it the public IP, or a private IP if you’re on the same network?
Even more frequently, the port number is the culprit. While SSH defaults to port 22, many system administrators change this for security reasons (often called “port knocking” or simply to make it harder for automated bots to find the service). If the remote server’s SSH daemon is configured to listen on, say, port 2222, and you’re trying to connect on port 22, the server will refuse the connection because nothing is listening on 22. In PuTTY, this is the ‘Port’ field under ‘Connection -> SSH’. Ensure it matches the server’s configuration. Edrater's troubleshooting guide offers useful background here.
Verifying Server-Side Port Configuration
To verify the SSH port on the server (again, requiring out-of-band access), you’ll need to look at the sshd_config file. This file is typically located at /etc/ssh/sshd_config. Open it with a text editor (like nano or vi) and look for a line that starts with Port. It might look like Port 22 or Port 2222. If this line is commented out (starts with a #), then the default port 22 is used. If it specifies a different port, that’s the one you need to use in PuTTY.
After changing the port in sshd_config, you must restart the SSH service for the change to take effect: sudo systemctl restart sshd. Failing to restart the service after a configuration change is another common error that leads to a persistent “PuTTY connection refused” message, even when you think you’ve fixed the port. (See: Common network troubleshooting techniques.)
SSH Configuration Errors: Beyond the Port
While the port is a big one, the /etc/ssh/sshd_config file holds many other settings that can lead to a “PuTTY connection refused” error, or at least prevent successful authentication. If the server is refusing the connection after the initial TCP handshake, it might be due to a misconfiguration in this file related to allowed users, authentication methods, or even a corrupted file itself.
Some common configuration pitfalls include:
PermitRootLogin no: If you’re trying to log in as ‘root’ and this setting is ‘no’, your connection attempt will be rejected during the authentication phase, often manifesting as a refusal, or more politely, a ‘Permission denied’. Best practice dictates creating a non-root user and usingsudo.AllowUsersorDenyUsers: These directives explicitly whitelist or blacklist users. If your username isn’t inAllowUsersor is inDenyUsers, you won’t get in.PasswordAuthentication no: If you’re trying to authenticate with a password but this is set to ‘no’, you’ll need to use SSH keys instead. If your keys aren’t set up correctly, this will effectively lock you out.- Incorrect file permissions: The
sshd_configfile and its parent directories need specific, restrictive permissions. If they are too permissive,sshdmight refuse to start or operate correctly. For example,/etc/ssh/sshd_configshould typically be 644 (-rw-r--r--) and owned by root.
Debugging with Verbose Output and Logs
When you’re facing a stubborn “PuTTY connection refused” issue due to server-side SSH configuration, looking at the server logs is paramount. The SSH daemon logs its activity, including connection attempts and failures, typically in /var/log/auth.log or /var/log/secure (depending on your Linux distribution). Use tail -f /var/log/auth.log (or secure) while attempting to connect from PuTTY. The log messages can often pinpoint the exact reason for the refusal, such as ‘Authentication failed’, ‘User not allowed’, or even ‘Bad permissions on key file’.
Another powerful debugging tool is to run sshd in debug mode, though this requires stopping the existing service first: sudo /usr/sbin/sshd -d. This will print verbose output directly to the console, showing exactly what sshd is doing as it processes your connection attempt. Be sure to restart the regular sshd service after debugging.
Client-Side Issues: Your PuTTY Configuration
While most “PuTTY connection refused” errors point to the server or network, sometimes the problem lies with your PuTTY client configuration. It’s easy to overlook your own settings when troubleshooting. Here are a few things to check:
- Incorrect Hostname/IP: As mentioned, a simple typo in the ‘Host Name (or IP address)’ field is a common mistake.
- Wrong Port: Ensure the ‘Port’ field (under Connection -> SSH) matches the port the SSH server is listening on.
- Authentication Method Mismatch: If the server expects key-based authentication and you’re trying to use a password (or vice-versa), PuTTY might display a refusal or ‘access denied’ depending on the server’s exact configuration. Verify your private key path under ‘Connection -> SSH -> Auth’ if you’re using keys. Make sure the key is in the correct format (
.ppkfor PuTTY). - Proxy Settings: Are you connecting through a proxy server? PuTTY has proxy configuration options under ‘Connection -> Proxy’. If these are misconfigured or no longer valid, they can prevent a direct connection and lead to a refusal.
- Saved Sessions: If you’re loading a saved session, ensure its settings haven’t become outdated. It’s sometimes better to start a fresh session to rule out old, incorrect configurations.
PuTTY’s Event Log for Client-Side Clues
PuTTY itself provides a valuable tool for troubleshooting: the Event Log. Before attempting a connection, go to ‘Session’ in the PuTTY configuration window, select ‘Logging’ under ‘Session’, and choose ‘SSH packets and raw data’ or ‘All session output’ to a log file. Then try to connect. The log file can often provide more granular detail about where the connection failed from the client’s perspective, such as specific authentication failures or negotiation issues, giving you more specific clues than just a generic “connection refused.”
Network Address Translation (NAT) and Port Forwarding
If your server is behind a router or gateway that uses Network Address Translation (NAT), then you’re dealing with another layer of complexity that can cause a “PuTTY connection refused” error. NAT allows multiple devices on a private network to share a single public IP address. For external connections to reach a specific device on the private network, ‘port forwarding’ (or ‘NAT punching’) must be configured on the router.
Here’s how it works: you connect to the router’s public IP address on a specific port (e.g., public_IP:2222). The router then needs a rule to forward incoming traffic on that public port to the private IP address of your server on its SSH port (e.g., 192.168.1.100:22). If this port forwarding rule is missing, incorrect, or if the router’s firewall blocks the incoming public port, your connection will be refused.
Troubleshooting NAT and Port Forwarding
To troubleshoot this, you’ll need access to your router’s administration interface. Look for sections like ‘Port Forwarding’, ‘NAT’, ‘Virtual Servers’, or ‘Firewall Rules’. Ensure there’s an entry that maps the public port you’re connecting to (e.g., 22 or a custom port like 2222) to the private IP address of your SSH server on its listening port (usually 22). Also, confirm that the server’s private IP address hasn’t changed (e.g., if it’s using DHCP and got a new address). Static IP assignment for servers behind NAT is always recommended. (See: SSH in computer science.)
This is particularly relevant for home lab setups, internal servers, or developers working with local VMs that need to be exposed to the internet. Cloud instances typically handle this with security groups and public IPs directly, so NAT issues are less common there, unless you’re connecting to an instance within a private subnet via a NAT Gateway or similar service.
DNS Resolution Problems: When Names Fail
While you might be connecting via an IP address, many people prefer hostnames (e.g., myserver.example.com). If you’re using a hostname and encounter a “PuTTY connection refused” error, it’s worth checking if DNS resolution is working correctly. If your client can’t translate the hostname into the correct IP address, it won’t even know where to send the connection request.
You can test DNS resolution from your local machine using tools like nslookup or dig (on Linux/macOS) or ping (which performs a DNS lookup first). For example, nslookup myserver.example.com should return the correct IP address. If it returns no address, an incorrect address, or times out, then you have a DNS issue.
Common DNS Scenarios to Check
- Incorrect DNS Records: Has the A record (for IPv4) or AAAA record (for IPv6) for your hostname been updated recently or is it simply wrong?
- DNS Server Issues: Is your local machine using reliable DNS servers? Sometimes, a slow or unresponsive DNS server can cause resolution failures.
- Local Hosts File: Check your local
hostsfile (C:\Windows\System32\drivers\etc\hostson Windows,/etc/hostson Linux/macOS). An entry there might be overriding public DNS and pointing to an old or incorrect IP address.
While a DNS issue won’t directly cause a server to refuse a connection (because the connection never reaches the server in the first place), it presents the same symptom from the user’s perspective: a failure to connect. It’s an important diagnostic step, especially when you’re sure everything else on the server is fine, and you can connect using the raw IP address.
When All Else Fails: The Systematic Approach
You’ve checked the server’s online status, firewalls, SSH service, port, configuration, and even your client settings. If you’re still seeing that stubborn “PuTTY connection refused,” it’s time for a more systematic, layered approach. Think of it as peeling an onion, one layer at a time, moving from the most general network connectivity to the most specific SSH service configuration.
- Verify Server Reachability (Ping): Can you ping the server’s IP? If not, the problem is network-wide or the server is down.
- Port Scan (Nmap/Telnet): Can you see if port 22 (or your custom SSH port) is open? From your local machine, use
telnet [server_ip] [port]. If it connects, you’ll see a blank screen or some garbled text. If it says ‘connection refused’ here, the problem is likely a server-side firewall orsshdnot running/listening on that port. Iftelnettimes out, it’s a network firewall blocking the connection. A more powerful tool is Nmap:nmap -p [port] [server_ip]. This will tell you if the port is ‘open’, ‘closed’, or ‘filtered’. ‘Closed’ usually meanssshdisn’t running or the port is refused by the OS, while ‘filtered’ means a firewall is blocking it. - Console Access and Server-Side Logs: Get direct console access to the server (cloud provider console, KVM, etc.). Check
sudo systemctl status sshd. Check/var/log/auth.logor/var/log/securefor any messages related to SSH connection attempts and failures. - Review
sshd_config: Carefully examine/etc/ssh/sshd_configfor any non-standard settings, especially those related toPort,PermitRootLogin,PasswordAuthentication,AllowUsers, orListenAddress. Restartsshdafter any changes. - Client-Side Logging in PuTTY: Enable verbose logging in PuTTY to capture the entire session. This can sometimes reveal subtle issues that aren’t immediately apparent.
- Test with a Different Client or Machine: Try connecting from a different computer or using a different SSH client (e.g., OpenSSH on Linux/macOS, or another Windows client). This helps isolate if the problem is specific to your PuTTY installation or local machine’s network.
Remember, the “PuTTY connection refused” error is a symptom, not a diagnosis. By systematically eliminating possibilities and using the right diagnostic tools, you can almost always pinpoint the root cause. Don’t get discouraged; every time you solve one of these, you deepen your understanding of network and server operations. Happy troubleshooting! See also P-20edcareers' resolution steps.
Trending Now
Frequently Asked Questions
Why does PuTTY say connection refused?
A 'connection refused' error in PuTTY usually indicates that the server is not accepting connections on the specified IP address and port. This could be due to the server being down, the SSH service not running, or firewall settings blocking the connection.
How do I fix PuTTY connection refused?
To resolve a 'connection refused' error in PuTTY, check if the server is online, ensure the SSH service is running on the server, and verify that the firewall settings allow traffic on the designated port (usually port 22).
What does it mean when a server refuses a connection?
When a server refuses a connection, it means that the server is actively rejecting the request. This can happen if the server is not configured to accept connections on the specified port, or if there are network issues preventing a successful connection.
Is port 22 always used for SSH connections?
Port 22 is the default port for SSH connections, but it can be changed for security reasons. If you're receiving a connection refused error, ensure you're trying to connect to the correct port configured on the server.
How can I check if my SSH server is running?
To check if your SSH server is running, you can use commands like 'systemctl status sshd' on Linux systems, or check the service status in your server's control panel. Ensuring the service is active is crucial for successful connections.
Have you experienced this yourself? We'd love to hear your story in the comments.




