How to set up Wi-Fi on Raspberry Pi? (5 ways on Raspbian)

It’s probably the most common question when installing your first Raspberry Pi, so I choose to write a guide about it to help you find the good solution in your specific case.
All recent Raspberry Pi models (Pi 3, 4 and Zero W) includes a wireless connection, but the configuration is not always easy, especially with a complex or secured network, or on Raspbian Lite.
I will answer all your questions in this post.

How to set up Wi-Fi on Raspberry Pi?
You have 5 ways to configure the Wi-Fi on Raspberry Pi:
– In headless mode, by adding files on your SD card.
– On Raspbian Desktop, either in the welcome wizard or from the task bar.
– Or on Raspbian Lite, with a manual configuration or the raspi-config tool

I’ll show you everything in this post. If you already know which solution is for you, feel free to use the table of contents below.

By the way, if you are really interested in improving your skills on Raspberry Pi, I highly recommend to check out my e-book hereIt’s a 30-days challenge from beginner to master, with step-by-step tutorials and many projects to practice along the way.

Raspberry Pi Wi-Fi Headless Configuration

I call this part “headless” because it’s the way you can use if you don’t have a screen on your Raspberry Pi.
But you can absolutely use it in any case. Besides, that’s what I do most of the time.


This solution applies if you just flashed your SD card, and want to enable Wi-Fi on your fresh system on the first boot (but it also works for an old SD card you used with Ethernet or an old wireless network).

You have a file to create and copy on the SD card, so on the next boot Raspbian will read the file and apply the configuration directly.
You don’t have anything else to do.
Good idea no?

Raspberry Pi Course
Sale: 10% off today. Take it to the next level.
I'm here to help you getting started on Raspberry Pi, and learn all the skills you need in the correct order.


Let’s see how to do this:

  • Open your favorite text editor on your computer.
    The basic editor from your operating system will be fine (Notepad for example).
  • Copy and paste these lines into it:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
  • Replace variables with your SSID and password, and change the country value if needed.
  • Save the file on a location you can find easily the next time you create a new SD card.

Insert your Raspbian SD card into your computer (for a fresh new SD card created with Etcher, you have to eject and insert it again).
Then copy the wpa_supplicant.conf file to the boot partition.

It works with any Raspbian version (Desktop or Lite).
So it’s perfect for any use.

Enable SSH automatically

Another thing you may want to add, if you really use your Raspberry Pi without screen, is to enable the SSH service automatically.
On Raspbian, it’s not the case by default. Even if your Pi connects to your wireless network, SSH will not be enabled.

To do this, there is another file to create.
Just create an empty file, named “ssh” into the same partition (boot).
It’s enough to tell Raspbian to start the SSH service automatically on boot.

Configure Wi-Fi on Raspbian Desktop

Let’s see now how to configure your Wi-Fi once you’re on Raspbian Desktop.

Welcome wizard

If it’s your first boot, you should get a “Welcome to Raspberry Pi” message, asking you to set up your system.
It’s the easiest way to do on Raspbian Desktop, don’t miss this menu.

After setting the country and password, you’ll get a window like this:

Select your Wi-Fi network SSID in the list, and type the password.
A few seconds later, you’ll be connected to your network.

Task bar

If you missed the welcome wizard, or skipped the Wi-Fi configuration here, you can do it or change it at anytime in the taskbar panel:

  • On the top you have the main panel, with the menu, shortcuts and the clock.
  • Near the clock, there is a network symbol (with two red crosses if you are disconnected).
  • Click on it, a list of all available wireless networks appears.
  • Select your network in the list, and type your password.

That’s it, not very complicated either 🙂

Set up your Wi-Fi on Raspbian Lite

If you’re on Raspbian Lite, you may need more help to find how to configure your network.
Let’s see how to do this.

Master your Raspberry Pi in 30 days
Sale: 25% off today. Download the eBook.
Uncover the secrets of the Raspberry Pi in a 30 days challenge.

Raspi-config tool

The Raspberry Pi Foundation thought of you.
Even you are on a black and white screen for pro, there is a tool to help you to configure your wireless network easily.

This tool is raspi-config, available by default on Raspbian Lite:

  • Start raspi-config with:
    sudo raspi-config
    raspi config
  • Go into Network Options > Wi-Fi.
  • Type your SSID and your password.
  • Exit the tool.
    After a few seconds, your Pi is now connected to the wireless network you chose.

That’s an easy way to do on Raspbian Lite.

Manual configuration

The last option is not easy, but only useful for specific network I think
In fact, I’m not sure when manual configuration is the only option.
Maybe on a big network with secure authentication, a critical device or static network?
Anyway, here is how to create a manual configuration, even if it’s just for your curiosity 🙂

WPA Supplicant

The wireless configuration on the Raspberry Pi is located in /etc/wpa_supplicant.
You can edit the configuration file with nano:
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

The syntax is the same as we saw in the first part, with the file you can put on your SD card.
You’ll find here the same information, so you can change them directly in this file if needed.
Here is a reminder of a basic configuration syntax with WPA-PSK:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev

If the new configuration doesn’t apply after a few minutes, you may need to reboot the Raspberry Pi:
sudo reboot

You can find many examples here to adapt the configuration to your network (if you use WEP, EAP or any other security options).

Network configuration

Finally, if you need a static IP on your network, the interface configuration can be done in dhcpcd.conf:

  • Open the file:
    sudo nano /etc/dhcpcd.conf
  • Find the “Example static IP configuration” paragraph.
  • Uncomment every line you need (probably ip_address, routers and domaine_name_servers), and change the values to adapt to your network.
  • Here is a basic example:
interface wlan0
static ip_address=
static routers=
static domain_name_servers=

Save and exit, then reboot the Raspberry Pi:
sudo reboot


That’s it, you know everything you need to set up the Wi-Fi on your Raspberry Pi, whatever your network.

I hope this post was helpful.
If you have anything else to add about this, thanks to post a comment, so it can help everyone.
As a general rule, it’s easy when you know what to do, but maybe I’ve never been in a situation where configuring Wi-Fi on the Raspberry Pi was complicated 🙂

Patrick Fromaget

I'm the lead author and owner of My goal is to help you with your Raspberry Pi problems using detailed guides and tutorials. In real life, I'm a Linux system administrator with a web developer experience.

3 thoughts on “How to set up Wi-Fi on Raspberry Pi? (5 ways on Raspbian)

  1. I run Motioneye on my PI, I have recently changed my home router, now the PI cannot log in because the router and password info is incorrect. I am unable to get to the command screen as Motioneye starts up on boot? how do I now change the router info please?

    1. Hi Ken,

      I suppose you want to say “motionEyeOS”
      I don’t know this OS, but in the wiki, they say that the configuration is in the wpa_supplicant.conf file, maybe /data/etc/wpa_supplicant.conf

      If you find it, you can edit the file with the default editor and update your settings

Leave a Reply

Your email address will not be published. Required fields are marked *

Recent Posts

Master your Raspberry Pi - eBook Sale