Skip to content
SSH9 min read14.08.2026

How to Fix SSH Connection Refused and Timed Out Errors

Both errors mean that an SSH session could not open, but they point to different stages of the connection. Reading the exact error prevents unnecessary password and key changes.

Connection refusedTimed outSSH portFirewall
Server address and port fields on the Varkuna SSH Quick Connect screen

Connection refused vs connection timed out

Connection refused usually means the target server was reached but no SSH service accepted the connection on the selected port. The SSH service may be stopped, listening on another port or explicitly rejecting the connection.

Connection timed out means the client received no response before its timeout. A wrong IP address, an offline server, a routing problem or a firewall silently dropping packets are common causes.

Before authentication

These errors normally happen before password or key authentication begins. Changing credentials will not fix an unresolved network or port problem.

Start with client-side checks

  1. 1
    Verify the server address

    Check the host name or IP again. Do not include http://, https://, spaces or extra characters.

  2. 2
    Verify the SSH port

    The default is 22, but the hosting provider or administrator may assign a custom port.

  3. 3
    Try another trusted network

    Switching between mobile data and trusted Wi-Fi can help identify a local network restriction.

  4. 4
    Compare with another client

    Test the same host and port from a desktop SSH client when possible. Failure on both devices points toward the server or network.

Confirm that the SSH service is running

If you can use the provider console, check the SSH service. Debian and Ubuntu commonly call it ssh; RHEL and Fedora-based systems commonly use sshd.

Test the configuration before restarting the service. A syntax error followed by a restart can also terminate your remaining path into the server.

Debian / Ubuntu
sudo systemctl status ssh
sudo sshd -t
RHEL / Fedora
sudo systemctl status sshd
sudo sshd -t
Show listening SSH ports
sudo ss -tlnp | grep ssh

Review the port and firewall

SSH configuration

The Port value in sshd_config must match the port in the client. Keep an existing session open while testing a change.

Server firewall

Check that UFW, firewalld or nftables permits only the SSH port you intend to use.

Cloud security group

A VPS or cloud network rule can block traffic independently of the firewall inside the server.

NAT and forwarding

For a server behind a router, confirm that the external port forwards to the correct internal IP and port.

Do not open every port

Instead of disabling the firewall, allow only the required SSH port and restrict source addresses when practical.

Separate DNS and IPv6 issues

A stale DNS record can direct the client to an old server. Compare the current address in the provider panel with the address resolved by the host name.

Some networks publish an IPv6 record even though the server does not accept SSH over IPv6. Testing with a verified IPv4 address can help isolate DNS or IPv6 behavior.

Ping is not decisive

A server can block ICMP ping while allowing SSH. A failed ping does not prove that the SSH service is unavailable.

Short troubleshooting order

  1. 1
    Identify the exact error

    Determine whether it says refused or timed out.

  2. 2
    Verify host and port

    Use the exact values supplied by the provider.

  3. 3
    Check the SSH service

    Use the server console to inspect the service and listening port.

  4. 4
    Check network rules

    Review the server firewall, cloud security group and any NAT forwarding.

  5. 5
    Then troubleshoot authentication

    Once the server asks for a password or key, the network stage has succeeded.

Continue

Put the guide into practice.

Review the related Varkuna product or open its detailed user guide.