LightAtom

SSH "Connection Refused": How to Fix It

The host is reachable but nothing accepted the SSH connection on that port: the SSH server isn't running, listens on another port, or a firewall rejects it.

ssh: connect to host port 22: Connection refused

Your Mac reached the server, and the server immediately said no on that port. No SSH service is listening there, or a firewall rejected the connection.

Quick checks

  • Check the host name or IP and the port (`-p 2222`).
  • Test the port: `nc -vz host 22`.
  • Is the server's SSH service running?

Fixes on Mac

  1. Connecting to a Mac? Turn on Remote Login

    1. On the Mac you connect to: System Settings › General › Sharing › Remote Login on.
    2. Check it's listening: sudo lsof -nP -iTCP:22 -sTCP:LISTEN should show launchd or sshd.
  2. Use the right port

    1. If the server uses a custom port, connect with ssh -p 2222 user@host or set Port in ~/.ssh/config.

Fixes on Windows

  1. Connecting to Windows

    1. Install the OpenSSH Server optional feature and start the sshd service.

Other devices

  1. Linux servers

    1. Start the service: sudo systemctl enable --now ssh (or sshd).
    2. Check the listening port: sudo ss -ltnp | grep ssh.
    3. Check firewalls: sudo ufw status or the cloud security group.

Still not working?

If the server just rebooted, sshd may still be starting. If you changed Port in sshd_config, make sure the firewall allows the new port before restarting sshd, or you can lock yourself out.

See what’s happening

LightAtom's Ports view shows whether your Mac is listening on port 22 when you've turned on Remote Login.

Frequently asked questions

What does SSH connection refused mean?

The host replied that nothing accepts connections on that port. The SSH server isn't running, is on another port, or a firewall actively rejects the connection.

How do I enable SSH on a Mac?

System Settings › General › Sharing › Remote Login. You can limit which users may connect.

What is the difference between refused and timed out?

Refused: the host answered no right away. Timed out: no answer at all, usually a firewall dropping traffic or the host being unreachable.

LightAtom team

The people who build LightAtom, a network monitor for macOS.