I am using a Raspberry Pi 2, running Debian Jessie, and I have a problem with my Wi-Fi connection, after setting my /etc/network/interfaces:

    # interfaces(5) file used by ifup(8) and ifdown(8)
    # Include files from /etc/network/interfaces.d:
    source-directory /etc/network/interfaces.d

    # uncomment the next 4 lines and set the correct wpa-ssid (network ssid) and
    auto lo
    iface lo inet loopback
    iface eth0 inet manual
    allow-hotplug wlan0
    iface wlan0 inet manual
         wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

and wpa_supplicant.conf:



then running wpa_cli reconfigure. I get the error, Failed to connect to non-global ctrl_ifname: (null) error: No such file or directory so need help. How can I resolve this?


8 Answers 8


This worked for me

sudo nano /etc/network/interfaces
and add the following lines

auto wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
file looks like this

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

ssid="your ssid"
psk="your wifi password"

source https://www.domoticz.com/forum/viewtopic.php?t=10930


I have a cluster of 12+ RPis that I am initializing headlessly. The same exact image works on some and fails on others with the message:

Failed to connect to non-global ctrl_ifname: wlan0  error: No such file or directory

This is how I'm doing the wifi config:

#### Wifi Setup (WPA Supplicant)
##  Replaces the magic of https://github.com/RPi-Distro/raspberrypi-net-mods/blob/master/debian/raspberrypi-net-mods.service
##  See: https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md
cat > /etc/wpa_supplicant/wpa_supplicant.conf << EOF
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev

    ssid="wifi name goes here"
    psk="password goes here"
chmod 600 /etc/wpa_supplicant/wpa_supplicant.conf
wpa_cli -i wlan0 reconfigure

Since it was the last line that was giving the error, I replace it with this:

until wpa_cli -i wlan0 reconfigure; do
  echo "Failed to reconfigure wlan0 with wpa_cli."
  echo "Restarting dhcpcd with systemctl."
  systemctl restart dhcpcd

I've never had it loop through more than once, but I put the until there just in case it didn't respond the first time. But, that comes with the risk of never escaping. For my need, I don't want the script to continue without an internet connection. You can decide what works for you. A single pass implementation might look like this:

wpa_cli -i wlan0 reconfigure || ( systemctl restart dhcpcd; wpa_cli -i wlan0 reconfigure; )
  • 1
    Wonderful answer! In the loop I had to insert sleep 5 after systemctl restart dhcpcd, because dhcp.service complained about start requests being repeated too quickly
    – mcguffin
    Commented Jan 28, 2020 at 18:23

I had a similar problem except for in /etc/network/interfaces I had two interfaces and was updating the wrong one! Ensure you're updating the correct interface.

I had the following and was updating wlan1 when I needed to update wlan0:

iface wlan0 inet static
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

iface wlan1 inet static
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

I ran into this problem when I ditched dhcpcd and chose systemd-networkd as network manager.

First, check how the wpa_supplicant service is launched by sudo systemctl status, if it indicates

/sbin/wpa_supplicant -u -s -O /run/wpa_supplicant

, then you got the problem.

The wpa_supplicant service requires interface and drivers to run properly. This is how dhcpcd launches wpa_supplicant:

wpa_supplicant -B -c/etc/wpa_supplicant/wpa_supplicant.conf -iwlan0-Dnl80211,wext

See the -i and -D options? Now you may shutdown your default blank wpa_supplicant service using sudo systemctl stop unit and launch a new one with these 2 options to see whether you still get the error and everything falls back to normal.

Since there is a service config file named [email protected] in /usr/lib/systemd/system, we could stop/disable the default service and start/enable the new [email protected], which launch service like

/sbin/wpa_supplicant -c/etc/wpa_supplicant/wpa_supplicant-wlan0.conf -Dnl80211,wext -iwlan0

which is exactly how we want it to be. But the first launch could fail because /etc/wpa_supplicant/wpa_supplicant-wlan0.conf does not exist. So just make a copy or symbolic link from the origin wpa_supplicant.conf, named wpa_supplicant-wlan0.conf. You are good to launch it again and success.


I was unable to get wpa_cli to connect to wlan0 on a Raspberry Pi 3B+, when using a user other than the "pi" user. I received the same error messages. After some research, I found that running the command below will add the user that you specify to the "netdev" group, and the error goes away. You've got to reboot after running the command.

sudo gpasswd -a [username] netdev

You may also be able to use: sudo usermod -a -G netdev [username]

  • You can't use wpa_cli on Raspbian because it not used - dhcpcd is the default.
    – Milliways
    Commented Oct 15, 2020 at 0:21
  • 2
    There's no conflict there -- wpa_cli is just an optional front end to wpa_supplicant, which dhcpcd uses, and pi users are required to configure manually anyway. linux.die.net/man/8/wpa_cli
    – goldilocks
    Commented Oct 15, 2020 at 15:22
  • It was a good point. Many tutorials propose to remove the pi user, but not every one adds the user to the netdev group. Commented Jan 13, 2021 at 22:20

I know this is closed, but this is how they solved it. They just connected the resolv config to Google Public DNS.

  1. Edit /etc/resolv.conf from your terminal.
nano /etc/resolv.conf
  1. Add this to it:
  1. Reboot.

I had the same problen. I had previously configured the Pi as an Access Point. So there was no entry in /etc/network/interfaces needed and none there.

After I added a network device to /etc/network/interfaces and rebooted, my problem disappeared

sudo cat > /etc/network/interfaces.d/20-wifi
auto wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

I solved my problem by adding the IP of GOOGLE to DNS because it was the problem

  • 4
    Could you please add some detail to your answer and mark it as correct
    – Darth Vader
    Commented Dec 25, 2017 at 12:32
  • 2
    How this could be possible? It's totally unrelated matter. Could you explain why do you think it was the solution?
    – Alex Yu
    Commented Jul 28, 2019 at 10:31

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.