Red Hat Bugzilla – Bug 1253798
lighttpd.service fails on boot
Last modified: 2017-05-01 19:53:18 EDT
I have an up-to-date CentOS 7 system with lighttpd 1.4.36-1.el7 installed from Fedora EPEL. When I reboot the system for updates and such, lighttpd fails to start on boot; systemctl status lighttpd.service shows:
Aug 14 09:21:34 hosting.cmadams.net lighttpd: 2015-08-14 09:21:34: (network.c.410) can't bind to port: 2001:408:0:6::179 80 Cannot assign requested address
I can log in and start it later just fine. It looks like the service is being started before the network is configured. I'm using the "old-style" network.service, not NetworkManager, and the above address is configured in /etc/sysconfig/network-scripts/ifcfg-etho. I see the systemd unit file for lighttpd.service does include network.service in After, and systemctl status network.service says:
Aug 14 09:21:33 hosting.cmadams.net systemd: Starting Network.
Aug 14 09:21:33 hosting.cmadams.net systemd: Reached target Network.
so it would seem that the network should have been up. I'm starting with lighttpd (since that's the only service that fails), but maybe there's something deeper going on?
Interesting. If you have it bind only to an ipv4 address, does it work?
Yes, it appears to be specific to IPv6.
I'm not sure what's happening actually. I put in a systemd service that ran a script before lighttpd.service that would watch to make sure the IPv6 address was assigned to the interface, but lighttpd still failed to bind it. Is there something in the kernel that would keep it from being bound right away?
I'm not really sure where to ask (don't know if there's an issue with the way lighttpd is trying to bind the IPv6 address, an issue with the kernel showing an address before it can be bound, or an issue with systemd coordinating/timing startup).
Does it behave the same way on Fedora?
Sorry it took a bit to test, but yes, it does have the same issue on Fedora 21 with lighttpd-1.4.36-1.fc21.x86_64. Setting it to listen on a specific IPv6 address means it won't start on boot.
(In reply to Jon Ciesla from comment #1)
> If you have it bind only to an ipv4 address, does it work?
Not for my CentOS 7.1 droplet at DigitalOcean.
lighttpd binds to a specific IPv4 address, and uses two non-standard ports.
Yesterday I rebooted the droplet, and lighttpd did not start.
"(network.c.410) can't bind to port: x.x.x.x xxxx Cannot assign requested address".
lighttpd runs OK when manually started.
Until I found this bug report I thought I'd misconfigured lighttpd.
Hmmm, this may be a more generic problem (possibly some race condition in systemd?). I just ran into a CentOS 7 server with rsyslogd configured to listen on a specific IPv4 address, and it had the same problem (couldn't bind to that IP at boot). In the rsyslogd case, it ran anyway, it just didn't listen on the network (so logs weren't logged).
Not sure where to go with this now...
Is this still occurring?
I don't have an easy way to test it at this point - I had to change my configs to bind IPs in other ways. I'll see what I can do, but it'll take me a bit.
I apologize; I haven't had a chance to check. I should have time next week.
However, I think this may be the underlying issue:
Okay, tested with a fresh and up-to-date CentOS 7 + lighttpd install. I just added a server.bind option to the default config, and lighttpd does still fail to start on boot because it can't bind. I added a systemd override for lighttpd with:
With that, it starts on boot fine. So, this is an instance of BZ 1119787, and changing the systemd unit file from network.target to network-online.target should fix it.
Excellent, thanks. I'll get a fix out ASAP.
lighttpd-1.4.44-1.1.el7 has been submitted as an update to Fedora EPEL 7. https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2016-854f12305e
lighttpd-1.4.44-1.1.el7 has been pushed to the Fedora EPEL 7 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2016-854f12305e
lighttpd-1.4.44-1.1.el7 has been pushed to the Fedora EPEL 7 stable repository. If problems still persist, please make note of it in this bug report.
tested with a fresh and up-to-date Fedora 25 + lighttpd 1.4.45. I just added a server.bind option to the default config, and lighttpd does still fail to start on boot because it can't bind. I added a systemd override for lighttpd with:
With that, it starts on boot fine. But before changing the systemd unit file from network.target to network-online.target, first activate the service: sudo systemctl enable NetworkManager-online.service, should fix it!