6

I have been trying to connect to my wireless network for several days now with my Raspberry Pi Zero W running Stretch (2017-08-16 release). I have read many threads on how to setup wifi, including the official guidelines from Raspberry Pi's website and this post but cannot figure out what I am doing wrong. I can see my wireless network using sudo iwlist wlan0 scan. Using sudo ifup wlan0 returns:

wpa_supplicant: /sbin/wpa_supplicant daemon failed to start
run-parts: /etc/network/if-pre-up.d/wpasupplicant exited with return code 1
ifup: failed to bring up wlan0

Here are the contents of my wpa_supplicant.conf file:

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

Network={
ssid="nowan"
psk="12qwaszx"
key_mgmt=WPA-PSK
}

Here are the contents of my /etc/network/interfaces file:

# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

iface eth0 inet manual

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

allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

Any advice/help would be greatly appreciated!

  • If you actually followed either of the links you quoted it should work. Is this fresh install or an upgrade? – Milliways Aug 23 '17 at 5:38
  • 1
    Thanks! Since I'm obviously missing it, please elaborate on how I have not done what the links suggest, or if I have made a mistake. It is a fresh install of stretch on a new Pi. – user6776314 Aug 23 '17 at 12:51
  • In Stretch there ain't any ifup anymore, it's systemd-networkd. Wpa supplicant is started by systemd. How /etc/network/interfaces still apply hasn't been explained. In particular, the wpa supplicant service is fixed to operate all wlan interfaces from a single wpa config file. Moreover I see that the wpa supplicant often disassociates even with proper keys. In my tests, hotplug failed. I would like to hear concrete recipes that can be reproduced how to get stretch working, especially from milliways. – TheDiveO Aug 23 '17 at 15:44
  • You haven't answered whether it is a new installation. In Stretch you should leave interfaces alone, and definitely not include wpa_supplicant. You have unnecessary lines in wpa_supplicant. – Milliways Aug 23 '17 at 23:02
  • I tried this like crazy - ONLY working solution I could find was to reinstall/downgrade to Jessie. Worked perfectly after that with nothing more than wifi info in /etc/wpa_supplicant/wpa_supplicant.conf or /boot/wpa_supplicant.conf – Brad Nov 26 '17 at 18:42
5

To get the WiFi working on a Pi Zero W only requires minimal config for Raspbian Stretch. The only file you need to modify is /etc/wpa_supplicant/wpa_supplicant.conf and this file needs to contain your WiFi network's SSID and password - which you add after the initial lines (the first 3 lines) that are already there so the file should look like something like this (country might be different for you):

country=GB
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
  ssid="mywifinetworkname"
  psk="my wifi password"
}

You don't need the /etc/network/interfaces file at all - The default setup in Raspbian Stretch does not contain an interfaces file. So just delete/move/edit the /etc/network/interfaces file if you have created one.

This just works as the wpa_supplicant service will just start up automatically if it finds its config file (/etc/wpa_supplicant/wpa_supplicant.conf) and connect the WiFi interface (wlan0) to the network. The default DHCP client dhcpcd attaches to all interfaces so it will then obtain an address.

If you want to assign static IP addresses or do other fancier network config you may then need to create an interfaces file or modify the /etc/dhcpcd.conf file.

And if you want the device to be accessible via ssh then you can create a file ssh in the /boot directory (remembering that if you're doing this to the micro SDcard on another machine - the boot dir is mounted on the first partition e.g. /dev/sdb1, and root would be on /dev/sdb2):

sudo touch /boot/ssh

Or if you're logged in just use systemctl:

sudo systemctl enable ssh.service
  • @user6776314: I would personally mark this answer as correct. It helped me realize I also had unnecessary modifications (like wpa-conf) in /etc/network/interfaces on Stretch, Raspi Zero W. Having the duplicate definition in interfaces file actually prevented me from reaching the pi properly over the network (ssh timeout). – plesatejvlk Apr 8 '18 at 11:27
4

You're most of the way there, I'll include full steps from a fresh install to my answer to help out other users. But this appears to be a bug in Stretch.

Make sure your wpa_supplicant.conf is in place then do

sudo nano /etc/network/interfaces

and add

allow-hotplug wlan0
iface wlan0 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

to the end of the file. Then do

sudo systemctl enable wpa_supplicant.service

Then reboot

  • Thank you for the response. I tried the method you suggested but it did not seem to work for me. I will double check my work and try again, and report back with the results. – user6776314 Sep 3 '17 at 15:59
3

Be aware that wpa supplicant is no exception to Linux rules: it is case sensitive!

In your wpa_supplicant.conf file, network={ is written with a capital N

That is already enough to make the parsing process fail...

-1

Setting up pimoroni optocam with motioneyes OS I came upon this problem.

Fixed it by:

  1. Editing the wpa_supplicant.conf I'd created using Notepad++ and in the Edit menu, changing the EOL setting to Linux.
  2. Copying wpa_supplicant.conf to my PC desktop
  3. Using Win32 Disk Imager to re-image the SD card from motioneyeos-raspberrypi-20180224.img
  4. Copying the wpa_supplicant.conf from my PC back onto the boot of the SD card
  5. Inserting into Pi zero and booting up

I think the problem was that I'd put incorrect wifi details into the wpa_supplicant.conf the first time I'd tried to boot up, and the Pi zero was using these details all the time. Even if I changed the wifi details in the wpa_supplicant.conf on the boot of the SD card, it made no difference. The only way to fix it was a clean image.

Someone should really make this work better. It's really confusing for noobs. Hope this helps someone.

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.