Board: Raspberry Pi 3 B+

OS: Raspian Stretch (with desktop and recommended software) 2018-11-13

I'm building an application that requires me to temporarily disable the wpa_supplicant service, while I update the wifi remotely.


  • I run 'sudo systemctl stop wpa_supplicant.service'
  • I append a wifi network to the wpa_supplicant.conf using a python script
  • I run 'sudo systemctl start wpa_supplicant.service'
  • I then have to run 'sudo systemctl restart dhcpcd.service', to see a list of available wireless connections again.

The problem is, even though I have a valid network in my wpa_supplicant.conf, it doesn't automatically try to connect at this point. I have to restart the Pi, and then it properly connects to my saved network.

I have tried 'sudo ifconfig wlan0 down' and then 'sudo ifconfig wlan0 up', but that doesn't do the trick.

  • Why do you want to do this? Raspbian Stretch doesn't use wpa_supplicant.service.
    – Milliways
    Mar 7, 2019 at 22:45
  • I'm stopping the service because I have a docker container that starts up and has it's own wpa_supplicant.service. They conflict. So I let the code run on the docker container, and then once I kill the container, I need the wifi to automatically connect to a saved connection.
    – M.Traynor
    Mar 8, 2019 at 14:51
  • Also, it definitely seems to use wpa_supplicant.service. If you start up a fresh install of the latest Raspian Stretch, and stop wpa_supplicant.service, pkill wpa_supplicant, you will not be able to connect to a wifi connection.
    – M.Traynor
    Mar 8, 2019 at 15:06

2 Answers 2


The problem is that default Raspbian uses dhcpcd for networking. It manages wpa_supplicant its own way as a hook and does not respect default service management. So using systemctl for wpa_supplicant has no meaning when using dhcpcd. systemctl status wpa_supplicant.service will mostly show you that it is disabled.

But to manage wpa_supplicant online you can use wpa_cli. Here are some steps to show how it could be integrated into your application. I have configured wpa_supplicant with my default network, but that is just not in range:

rpi ~$ wpa_cli -iwlan0 list_networks
network id / ssid / bssid / flags
0       default_Net     any

rpi ~$  iw dev wlan0 link
Not connected.

Then add the current network that is just available, to /etc/wpa_supplicant/wpa_supplicant.conf. I use bash instead of python:

rpi ~$ sudo bash -c 'cat >> /etc/wpa_supplicant/wpa_supplicant.conf <<EOF

Now reconfigure wpa_supplicant:

rpi ~$ wpa_cli -iwlan0 reconfigure

rpi ~$ wpa_cli -iwlan0 list_networks
network id / ssid / bssid / flags
0       default_Net     any
1       current_Net     any     [CURRENT]

rpi ~$  iw dev wlan0 link
Connected to b8:27:eb:86:d0:2d (on wlan0)
        SSID: current_Net
        freq: 2437
        RX: 1746 bytes (12 packets)
        TX: 5134 bytes (35 packets)
        signal: -54 dBm
        tx bitrate: 1.0 MBit/s

        bss flags:      short-slot-time
        dtim period:    2
        beacon int:     100

So for your application you only need two steps:

  • append a wifi network to the wpa_supplicant.conf using a python script
  • run '/sbin/wpa_cli -iwlan0 reconfigure'
  • This answer is misleading. Using dhcpcd is not a "problem" it is feature - it is a sophisticated network manager. "systemctl has no meaning when using dhcpcd" is just plain wrong as systemctl status dhcpcd would show. It is unclear WHY the OP feels the need to disable anything.
    – Milliways
    Mar 8, 2019 at 2:05
  • 1
    @Milliways dhcpcd is an antiquated system that is very bad integrated in modern upcoming operating system management that nearly all linux distributions uses today.
    – Ingo
    Mar 8, 2019 at 2:25

Raspbian Stretch does not normally use wpa_supplicant.service as shown by systemctl status wpa_supplicant.service

● wpa_supplicant.service - WPA supplicant
   Loaded: loaded (/lib/systemd/system/wpa_supplicant.service; disabled; vendor preset: enabled)
   Active: inactive (dead)

That is not to say it doesn't use wpa_supplicant as shown by systemctl status dhcpcd.service

● dhcpcd.service - dhcpcd on all interfaces
   Loaded: loaded (/lib/systemd/system/dhcpcd.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2019-03-04 17:23:49 AEDT; 4 days ago
  Process: 354 ExecStart=/usr/lib/dhcpcd5/dhcpcd -q -b (code=exited, status=0/SUCCESS)
 Main PID: 361 (dhcpcd)
   CGroup: /system.slice/dhcpcd.service
           ├─361 /sbin/dhcpcd -q -b
           └─477 wpa_supplicant -B -c/etc/wpa_supplicant/wpa_supplicant.conf -iwlan0 -Dnl80211,wext

dhcpcd starts wpa_supplicant with /lib/dhcpcd/dhcpcd-hooks/10-wpa_supplicant It is instructive to read the comments in this file:-

# Start, reconfigure and stop wpa_supplicant per wireless interface.
# This is needed because wpa_supplicant lacks hotplugging of any kind

Raspbian Jessie started wpa_supplicant in /etc/network/interfaces (although this was done by wpa-conf and I am not sure wpa_supplicant.service was ever invoked).

Normally if you make any changes to wpa_supplicant.conf you would restart dhcpcd.

NOTE is is possible (and common) to have multiple instances of wpa_supplicant running.

Hopefully this answers some of your questions, but from your Comments you are doing something else, which was not in your Question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.