Ad Space — Top Banner

SSH Connection Refused

Raspberry Pi Single-Board Computer

Severity: Minor

What Does This Error Mean?

Connection refused means the SSH server is not running on the Pi, or SSH is disabled. SSH is disabled by default on Raspberry Pi OS for security. Enable it using raspi-config, the Raspberry Pi Imager, or by placing an ssh file on the boot partition.

Affected Models

  • Raspberry Pi 5
  • Raspberry Pi 4B
  • Raspberry Pi 3B+
  • Raspberry Pi Zero 2 W
  • Raspberry Pi 400

Common Causes

  • SSH is disabled by default on fresh Raspberry Pi OS installs
  • SSH service crashed or failed to start
  • Firewall blocking port 22
  • Wrong IP address — the Pi is at a different address than expected
  • Pi is not connected to the network

How to Fix It

  1. Enable SSH in Raspberry Pi Imager before flashing.

    In Raspberry Pi Imager, click the settings gear icon before flashing. Check Enable SSH and set a username and password. This is the easiest way to enable SSH on a headless Pi.

  2. Or create an empty file called ssh on the boot partition.

    Put the SD card in your computer. Create an empty file called ssh (no extension) in the boot partition. The Pi enables SSH on the next boot and deletes the file.

  3. Or enable SSH via raspi-config (if you have a monitor connected).

    Open a terminal and run: sudo raspi-config. Go to Interface Options > SSH > Enable.

  4. Check the Pi's IP address.

    If you do not know the Pi's IP, check your router's admin page for connected devices. Or use a network scanner app to find devices named raspberrypi.

Frequently Asked Questions

Why is SSH disabled by default?

Raspberry Pi OS disabled SSH by default in 2016 for security. With SSH enabled and the default password unchanged, any Pi on a network was accessible to anyone. Now you must explicitly enable it and set a password.

Can I use SSH over USB on a Pi Zero?

Yes. The Pi Zero and Zero 2 W support USB OTG gadget mode. With the right config, you can SSH over the USB cable without a network connection.