beta-tester
Posts: 1221
Joined: Fri Jan 04, 2013 1:57 pm
Location: de_DE

Failed to start hostapd.service: Unit hostapd.service is masked.

Mon Mar 11, 2019 7:50 pm

hello,
yesterday i installed my RPi3B+ server newly from a clean image an run into an issue while setting up an access point.
i installed the current Raspbian image (2018-11-13-raspbian-stretch.zip) to my SD card, added an SSH file to the boot partition, to have ssh enabled just after first reboot.

at the first reboot (after automatic resizing/growing filesystem pass) i could shortly see a message with something like that the WiFi was disables because of unsetted country code or something similar popping through the slpash-screen.

from SSH i ran

Code: Select all

sudo raspi-config
to setup I4: WiFi country code to DE for Germany.

after

Code: Select all

sudo apt update && sudo apt upgrade -y
i installed packages

Code: Select all

sudo apt install -y dnsmasq hostapd
to be able to setup Wifi AccessPoint i tried to setup my RPi3B+ folowed the steps for
Setting up a Raspberry Pi as an access point in a standalone network (NAT)

but when i tried to start/enable hostapd with

Code: Select all

sudo systemctl start hostapd
i only got an error message

Code: Select all

Failed to start hostapd.service: Unit hostapd.service is masked.
luckily i found exact the same issue in an issue report on github Failed to start hostapd.service: Unit hostapd.service is masked.,
and by coincidence the user XECDesign is just preparing an updated documentation for setting up an access point so the user XECDesign was so kind, to pointing me to the right commands to unmask the masked hostapd service.

Code: Select all

sudo systemctl unmask hostapd
sudo systemctl enable hostapd
sudo systemctl start hostapd
but where is that issue coming from, that the WiFi is "locked down"?
i mean i setted up the WiFi country code in raspi-config, but WiFi wasn't unlocked automatically...

and i mean, that WiFi wasn't working at all out of the box - i couldn't see a network icon for WiFi on the screen/taskbar...
and on the welcome/configuration screen i mean the first time it shoed me a wrong IP address.
at installation and setup time the RPi3B+ was connected via LAN cable, and had an additional USB-LAN-adapter attached.
{ I only give negative feedback }
RPi Model B (rev1, 256MB) & B (rev2, 512MB) & B+, RPi2B (1GB), 64GB microSDXC1 class 10, HDMI 1920x1080, keyboard-mouse-combo (wireless), PiCamera, ethernet-cable, 5V/1.2A power supply, Wifi dongle (rt5370)

epoch1970
Posts: 2772
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Failed to start hostapd.service: Unit hostapd.service is masked.

Mon Mar 11, 2019 9:19 pm

Wifi didn't start because Raspbian mandates a valid country code, otherwise rfkill blocks the interface.
Users can drop a wpa_supplicant.conf file in the boot partition, and that file normally provides the country code. For them, wifi "just works".
Otherwise you have to use raspi-config, and perhaps reboot afterwards (?)

Then you stumbled on an unrelated and recent issue. The debian maintainers have been updating the hostapd package, and that surprised a few Rasbian users in turn.
viewtopic.php?f=66&t=235105#p1439522

Things will settle soon I believe.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

beta-tester
Posts: 1221
Joined: Fri Jan 04, 2013 1:57 pm
Location: de_DE

Re: Failed to start hostapd.service: Unit hostapd.service is masked.

Tue Mar 12, 2019 6:47 am

epoch1970 wrote:
Mon Mar 11, 2019 9:19 pm
Users can drop a wpa_supplicant.conf file in the boot partition, and that file normally provides the country code. For them, wifi "just works".
oops, that option i missed. didn't know or already forgot, that it is possible. thank you.
i only could remember to the ssh file to enable ssh out of the box.
epoch1970 wrote:
Mon Mar 11, 2019 9:19 pm
Then you stumbled on an unrelated and recent issue. The debian maintainers have been updating the hostapd package, and that surprised a few Rasbian users in turn.
viewtopic.php?f=66&t=235105#p1439522
yes, those kind of "wpa" and "tls" messages i could observe on my update/upgrade output as well.
but i can't remember if it was only on the frist try of installation (where i tried many different things to get WiFi working without success) or on both installation (where "i know how" to get WiFi working). i did a clean installation twice.
at first installation, i could set WiFi country code at first boot successfully, but after a reboot WiFi still wasn't working. then i tried it again to set the wifi country code, but then i got an error message in raspi-config, that wifi country code couldn't be setted, because raspi-config couldn't connect to the needed service. so the first try of clean installation of raspbian was a disaster.

i think at first clean installation i was doing sudo apt update && sudo apt full-upgrade -y before i setted the wifi country code.
at second clean installation i setted the wifi country code first and then did sudo apt update && sudo apt full-upgrade -y.
{ I only give negative feedback }
RPi Model B (rev1, 256MB) & B (rev2, 512MB) & B+, RPi2B (1GB), 64GB microSDXC1 class 10, HDMI 1920x1080, keyboard-mouse-combo (wireless), PiCamera, ethernet-cable, 5V/1.2A power supply, Wifi dongle (rt5370)

Milliways
Posts: 389
Joined: Fri Apr 25, 2014 12:18 am
Location: Sydney, Australia

Re: Failed to start hostapd.service: Unit hostapd.service is masked.

Sun Apr 07, 2019 8:21 am

The latest update to Raspbian (2019-03-09) has changed hostapd "wpa (2:2.6-10)".



You should run sudo systemctl unmask hostapd and sudo systemctl enable hostapd to ensure it runs on boot.

JonnyQuest
Posts: 13
Joined: Sat Apr 06, 2019 3:09 am

Re: Failed to start hostapd.service: Unit hostapd.service is masked.

Sun Apr 07, 2019 6:35 pm

When will the update be available? The downloads for raspberrypi.org only lists 2018-11-13.

Return to “Troubleshooting”