Fix SSH Connection Refused on Raspberry Pi¶
When SSH says Connection refused, the TCP connection was rejected before the login started. First confirm that your client used the Pi's current IP and the intended port. Then check whether an SSH server is listening there. A firewall can also reject the connection. Linux connect errors
Confirm the address and port on the client¶
Use your router's device list or a terminal on the Pi to confirm its current LAN address. A Pi can receive a different address after moving networks or renewing its DHCP lease. If you can open a terminal on the Pi, ip -brief address shows which addresses are on its Ethernet and Wi-Fi interfaces. Find your Pi on the network
Check the hostname and port lines in ssh -G for any settings applied by your client. In the verbose output, the Connecting to line shows the destination for that connection. If the direct IP works while a .local name fails, check how that name resolves. OpenSSH client manual · Fix a Pi's .local hostname
Check the SSH listener on the Pi¶
Use a local terminal or another working connection to the same Pi. If you have no way to open a shell on it, start with the headless recovery checks. Headless setup troubleshooter
| What you see | What to do |
|---|---|
| SSH is inactive and no listener appears | Enable SSH if you want remote access. In sudo raspi-config, select Interfacing Options → SSH → Yes, then rerun the listener check. |
ssh.service is failed |
Check its journal and configuration before trying to start it again. |
Only 127.0.0.1:22 or [::1]:22 appears |
That listener is reachable from the Pi itself. Check whether SSH is configured to listen on the Pi's LAN address. |
| The intended LAN address is listening, or SSH listens on all addresses for that IP family | Check filtering or rejection on the Pi and the path from the client. Also check whether another program owns the port by reading the process column. |
Use your configured port in the ss filter if it differs from 22. Enable SSH on Raspberry Pi OS · ss manual
If the service failed, inspect its error and use OpenSSH's configuration test. It reports errors without starting a second server.
Retry the same client connection once the expected address and port are listening. A password prompt or Permission denied (publickey) means you reached the login stage. If the host key warning appears, verify the Pi's identity before accepting a new key. SSH account and key checks · Verify a changed host key
On a Pi 4B running Trixie, a loopback connection to a test port with no listener returned Connection refused. The Pi's normal port 22 showed IPv4 and IPv6 listeners in ss and returned an OpenSSH protocol banner on loopback.