0

I have multiple errors while trying to start Hostapd I will post the errors output which i got after i tried to start it and looked at the status:

   root@l0calh0st:~# service hostapd status
● hostapd.service - Advanced IEEE 802.11 AP and IEEE 802.1X/WPA/WPA2/EAP Authenticator
   Loaded: loaded (/lib/systemd/system/hostapd.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Sun 2018-01-07 16:42:38 CET; 4s ago
  Process: 1682 ExecStart=/usr/sbin/hostapd -P /run/hostapd.pid -B $DAEMON_OPTS ${DAEMON_CONF} (code=exited, sta

Jan 07 16:42:38 l0calh0st systemd[1]: Starting Advanced IEEE 802.11 AP and IEEE 802.1X/WPA/WPA2/EAP Authenticato
Jan 07 16:42:38 l0calh0st hostapd[1682]: Configuration file:
Jan 07 16:42:38 l0calh0st hostapd[1682]: Could not open configuration file '' for reading.
Jan 07 16:42:38 l0calh0st hostapd[1682]: Failed to set up interface with
Jan 07 16:42:38 l0calh0st hostapd[1682]: Failed to initialize interface
Jan 07 16:42:38 l0calh0st systemd[1]: hostapd.service: Control process exited, code=exited status=1
Jan 07 16:42:38 l0calh0st systemd[1]: hostapd.service: Failed with result 'exit-code'.
Jan 07 16:42:38 l0calh0st systemd[1]: Failed to start Advanced IEEE 802.11 AP and IEEE 802.1X/WPA/WPA2/EAP Authe

I dont know why he dont find the configuration file he seems to search for ' ' aka nothing...! I don't edited anything....! Here if i try to start it normal:

root@l0calh0st:~# service  hostapd start
Job for hostapd.service failed because the control process exited with error code.
See "systemctl status hostapd.service" and "journalctl -xe" for details.

If use the command "journalct1 -xe" i get:

root@l0calh0st:~# journalctl -xe
-- Unit systemd-tmpfiles-clean.service has finished starting up.
-- 
-- The start-up result is RESULT.
Jan 07 16:57:44 l0calh0st systemd[1]: Starting Advanced IEEE 802.11 AP and IEEE 802.1X/WPA/WPA2/EAP Authenticator...
-- Subject: Unit hostapd.service has begun start-up
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- 
-- Unit hostapd.service has begun starting up.
Jan 07 16:57:44 l0calh0st hostapd[1865]: Configuration file:
Jan 07 16:57:44 l0calh0st hostapd[1865]: Could not open configuration file '' for reading.
Jan 07 16:57:44 l0calh0st hostapd[1865]: Failed to set up interface with
Jan 07 16:57:44 l0calh0st hostapd[1865]: Failed to initialize interface
Jan 07 16:57:44 l0calh0st systemd[1]: hostapd.service: Control process exited, code=exited status=1
Jan 07 16:57:44 l0calh0st systemd[1]: hostapd.service: Failed with result 'exit-code'.
Jan 07 16:57:44 l0calh0st systemd[1]: Failed to start Advanced IEEE 802.11 AP and IEEE 802.1X/WPA/WPA2/EAP Authenticator.
-- Subject: Unit hostapd.service has failed
-- Defined-By: systemd 
-- Unit hostapd.service has failed.
-- 
-- The result is RESULT.
lines 1521-1543/1543 (END)

Edit: Ok, i found the file "hostapd.service" but i don't see anything commented-out. (#?):

[Unit]
Description=Advanced IEEE 802.11 AP and IEEE 802.1X/WPA/WPA2/EAP Authenticator
After=network.target

[Service]
Type=forking
PIDFile=/run/hostapd.pid
EnvironmentFile=/etc/default/hostapd
ExecStart=/usr/sbin/hostapd -P /run/hostapd.pid -B $DAEMON_OPTS ${DAEMON_CONF}

[Install]
WantedBy=multi-user.target

This is the /etc/default/hostapd file:

# Defaults for hostapd initscript
#
# See /usr/share/doc/hostapd/README.Debian for information about alternative
# methods of managing hostapd.
#
# Uncomment and set DAEMON_CONF to the absolute path of a hostapd configuration
# file and hostapd will be started during system boot. An example configuration
# file can be found at /usr/share/doc/hostapd/examples/hostapd.conf.gz
#
#DAEMON_CONF=""

# Additional daemon options to be appended to hostapd command:-
#   -d   show more debug messages (-dd for even more)
#   -K   include key data in debug messages
#   -t   include timestamps in some debug messages
#
# Note that -B (daemon mode) and -P (pidfile) options are automatically
# configured by the init.d script and must not be added to DAEMON_OPTS.
#
#DAEMON_OPTS=""
  • Launch hostpad by hand to see the errors. In your question, you also fail to explain what changes you made to arrive to this state. – Rui F Ribeiro Jan 7 '18 at 16:39
  • Thanks for your answer! But I don't edited anything...! And i don't understand what do you mean "by Hand"? – ABeater Jan 7 '18 at 16:59
  • 1
    I am not familiar with hostapd but it looks like you're supposed to uncomment the DAEMON_CONF="" line and populate it with the path of your config file. Something like DAEMON_CONF="/etc/hostapd/default.conf" If you read right above the line with the commented DAEMON_CONF you can see the path to an example. – Zachary Brady Jan 8 '18 at 16:21
3

Your system is using systemd. In some distributions, I've noticed that using the legacy service wrapper can hide some error messages that would be visible using the systemd-native systemctl command. But it looks like there is enough information here.

In /lib/systemd/system/hostapd.service file, the line that determines the actual command used to start hostapd is apparently this:

ExecStart=/usr/sbin/hostapd -P /run/hostapd.pid -B $DAEMON_OPTS ${DAEMON_CONF}

Since it includes environment variables that are outside systemd's default set (see man systemd.exec for details), the hostapd.service file should probably have an option like Environment=, EnvironmentFile= or PassEnvironment=. Probably something like:

EnvironmentFile=/etc/default/hostapd.conf

If such a file exists, it probably has some commented-out defaults you'll need to edit to match your system configuration and then uncomment, before you can start hostapd.

Usually such files are prepared by your distribution maintainers, and have helpful comments describing what you'll need to do. If not, there might be some distribution-specific information in /usr/share/doc/hostapd-*/ directory which you should read first.

  • Thanks for the answer! I edited my post because i found the file but don't see anything commented-out. ( # ) – ABeater Jan 7 '18 at 16:57
  • Are the DAEMON_OPTS and DAEMON_CONF environment variables defined in the /etc/default/hostapd file? What are their values? – telcoM Jan 7 '18 at 17:00
  • mhhh i found the file, and copied it in my post. I think the variables are defined there but i dont understand what to do? – ABeater Jan 7 '18 at 17:10
  • 1
    Now it's just a matter of following the instructions in it: get the example configuration file and copy it to somewhere e.g. zcat /usr/share/doc/hostapd/examples/hostapd.conf.gz | sudo tee /etc/hostapd.conf, then edit /etc/hostapd.conf to suit your requirements, uncomment and edit the DAEMON_CONF variable in /etc/default/hostapd to point to /etc/hostapd.conf and you should be ready to start hostapd. – telcoM Jan 7 '18 at 17:15
  • Thank you!!! The Error with the configuration file is now away..! But i still get the Errors with "systemd[1]" in front of them and the "(code=exited, status=1/FAILURE)" but i will look if this disapeares after I edited the configuration file. – ABeater Jan 7 '18 at 17:40

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.