How to connect a Raspberry Pi to Wi-Fi
You can connect a Raspberry Pi to Wi-Fi in two ways: through the graphical interface if you have a monitor and keyboard plugged in, or through the command line if you are working remotely. The graphical method takes about five minutes and requires no typing of commands. The command-line method works when you cannot use a monitor, but you need to know your Wi-Fi network name and password beforehand. Both methods work on any Raspberry Pi model that has built-in Wi-Fi — that includes the Pi 3, Pi 4, Pi 5, and all Zero W models.
Before you start, make sure your Raspberry Pi is powered on and running Raspberry Pi OS. If you have just installed the operating system, you may see a setup wizard on first boot — you can use that wizard to connect to Wi-Fi when ready, or skip it and follow the steps below.
Key Takeaways
- The easiest method is clicking the Wi-Fi icon in the top-right corner of the desktop and selecting your network name from the list.
- If you do not have a monitor, you can add Wi-Fi details to the SD card before the first boot using a text editor on another computer.
- Your Raspberry Pi needs to be within range of your router and your Wi-Fi network must be broadcasting its name (SSID).
- Once connected, your Pi will remember the network and reconnect automatically when it boots up in the future.
- If the connection fails, check that you typed your password correctly — Wi-Fi passwords are case-sensitive.
Connecting through the desktop (with a monitor)
If you have a monitor, keyboard, and mouse connected to your Raspberry Pi, look at the top-right corner of the desktop. You will see a Wi-Fi icon that looks like a fan or radio waves. Click it once.
A list of available networks will appear. Find your network name in the list and click it. A box will pop up asking for your Wi-Fi password. Type it carefully — passwords are case-sensitive, which means capital letters and lowercase letters are different. Click the OK button when you are done.
The Pi will attempt to connect. You should see a spinning icon next to the Wi-Fi symbol while it is connecting. Within 10 to 20 seconds, the icon should stop spinning and show a solid signal. Your Pi is now on Wi-Fi. You can verify this by opening a web browser and visiting any website.
If the connection fails and you see an error message, go back and check your password. The most common mistake is typing a capital letter as lowercase or vice versa. If you are not sure of your password, you can check it on another device that is already connected to the network, or log into your router's settings page from a computer.
Connecting without a monitor (before first boot)
If you do not have a monitor available, you can add your Wi-Fi details to the SD card before you insert it into the Pi. This method requires a computer with an SD card reader and a text editor — any computer with Windows, Mac, or Linux will work.
After you have written Raspberry Pi OS to the SD card using Raspberry Pi Imager, do not eject it yet. On Windows, the SD card will appear as a drive in File Explorer. On Mac or Linux, it will appear on the desktop or in the file manager. Open the drive and look for a file called wpa_supplicant.conf. If you do not see it, you may need to show hidden files — on Windows, press Ctrl+H; on Mac, press Command+Shift+Period.
Open the wpa_supplicant.conf file with a text editor like Notepad (Windows), TextEdit (Mac), or gedit (Linux). At the bottom of the file, add these lines, replacing NETWORK_NAME with your actual Wi-Fi network name and PASSWORD with your actual password:
network={ ssid="NETWORK_NAME" psk="PASSWORD" }
Save the file, eject the SD card safely, insert it into your Raspberry Pi, and power it on. The Pi will connect to Wi-Fi automatically on first boot. This method works even if your network name contains spaces or special characters — just type it exactly as it appears when you look for networks on your phone.
Connecting through the command line (if you already have SSH access)
If you are already connected to your Pi through SSH or have a terminal window open, you can configure Wi-Fi without a graphical interface. Open a terminal and type the following command:
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
This opens a text editor in the terminal. Scroll to the bottom of the file using the arrow keys. Add the same network block as above, replacing NETWORK_NAME and PASSWORD with your actual details. Press Ctrl+X, then Y, then Enter to save and exit.
Restart the Wi-Fi service by typing:
sudo systemctl restart wpa_supplicant
Wait 10 seconds, then check if you are connected by typing:
iwconfig wlan0
If the output shows your network name next to SSID, you are connected. If it shows "Not-Associated", check your password and try again.
What to do if your Pi does not find your network
If your network name does not appear in the list of available networks, the most common cause is that your router is not broadcasting the network name. This is a security setting on your router. You can still connect by typing the network name manually instead of selecting it from the list. On the desktop, click the Wi-Fi icon, look for an option to enter a network name manually or "hidden network", and type your network name exactly as it is set in your router.
If your Pi finds the network but cannot connect, check that you are within range of your router — Raspberry Pi Wi-Fi antennas are not very powerful, and walls or distance can cause connection problems. Move the Pi closer to the router and try again. You can also check if your router is using Wi-Fi 6 (802.11ax) on the 6 GHz band, which some older Pi models do not support — if so, connect to the 5 GHz or 2.4 GHz band instead.
Checking your connection and IP address
Once your Pi is connected, you may want to know its IP address so you can connect to it from another computer. On the desktop, click the Wi-Fi icon and look for a menu option that shows connection details. You will see an IP address listed — it usually starts with 192.168 or 10.0.
From the command line, type:
hostname -I
This will display your Pi's IP address. Write it down if you plan to use SSH or remote access. The address will stay the same as long as your Pi remains connected to the same network, though it may change if you restart your router.
Switching to a different Wi-Fi network
If you need to connect to a different network, the process is the same as the first time. Click the Wi-Fi icon on the desktop, select the new network, and enter the password. Your Pi will forget the old network and remember the new one. If you want to keep both networks saved so the Pi can switch between them automatically, you can add multiple network blocks to the wpa_supplicant.conf file — the Pi will connect to whichever one is available.
To add a second network, open the configuration file again (either through the desktop settings or by editing the file directly) and add another network block below the first one with the new network name and password. The Pi will try to connect to the first network it finds available.
Frequently Asked Questions
Can I connect my Raspberry Pi to Wi-Fi without knowing the password?
No. Wi-Fi networks are encrypted, and your Pi needs the correct password to join. If you have forgotten your password, you can reset it through your router's settings page on a computer that is already connected, or contact your internet provider for help.
Why does my Raspberry Pi keep disconnecting from Wi-Fi?
Disconnections usually happen because the Pi is too far from the router, there is interference from other devices, or the power supply is unstable. Move the Pi closer to the router, check that no microwaves or cordless phones are running nearby, and make sure you are using the official power supply or one rated for at least 2.5 amps.
Can I use a USB Wi-Fi adapter instead of the built-in Wi-Fi?
Yes. If your Pi model does not have built-in Wi-Fi or the built-in Wi-Fi is not working, you can plug a USB Wi-Fi adapter into any USB port. The Pi will detect it automatically and you can connect the same way — through the desktop icon or the configuration file.
What if I typed my password wrong and now my Pi will not connect?
If you added the password to the configuration file before first boot, you will need to edit the file again on another computer. Remove the incorrect network block and add the correct one with the right password. If you are already booted, use the desktop Wi-Fi menu to forget the network and reconnect with the correct password.
Will my Raspberry Pi reconnect to Wi-Fi automatically after a power outage?
Yes. Once your Pi has connected to a network, it will remember it and reconnect automatically whenever it boots up, as long as the network is available. You do not need to enter the password again.