raspi-user.france
Posts: 15
Joined: Mon Jan 09, 2017 11:31 am

Could not bind to address - Services fail to start

Thu Aug 01, 2019 9:35 am

I encounter an issue with services not starting on boot with the error that they could not bind to an IP address. This is happening on Raspbian Stretch and Buster. Services affected are e.g. dnsmask, nginx, or apache2. I can easily start the manually after booting fully completed. The issue I think goes back to a bind to the WLAN IP address which probably takes too long to be assigned (via DHCP) so it's not yet there when systemd tries to start these services.

I assume there should be another dependency for those services in systemd to ensure there will be an IP address assigned to wlan0 interface first. This is where I'm not sure what to do (I also don't want to mess up with systemd files too much). As an example, on Buster I see for apache2 (using "systemctl cat apache2.service"): "After=network.target remote-fs.target nss-lookup.target". So there should be another "After"-target to ensure I have an IP on the WLAN, but I have currently no clue what this needs to be.

Anyone else having similar issues and knows about the right and proper systemd configuration to use?

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

Re: Could not bind to address - Services fail to start

Thu Aug 01, 2019 10:06 am

Systemd doesn’t know what first and last mean. He knows early and late, but that is all.
Many modern Linux distros incl. Raspbian use a fully dynamic network configuration, where links and subsequent configuration come and go.
In this context binding to and IP address does not make sense. Dnsmasq has a well known failure mode when using bind-interface, the author added bind-dynamic as a remedy. I don’t know if the others cared to provide a workaround.

In Raspbian you can specify “wait for network” when booting (in raspi-config). I’m not sure of the impact of that option but it might help.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Return to “Troubleshooting”