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?


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

| improve this answer | |

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
| improve this answer | |

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; )
| improve this answer | |
  • 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 Jan 28 at 18:23

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]

| improve this answer | |
  • You can't use wpa_cli on Raspbian because it not used - dhcpcd is the default. – Milliways Oct 15 at 0:21
  • 1
    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 Oct 15 at 15:22

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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