Interview Prep/Linux/systemd services and journald

A service starts fine manually but fails at boot because the network isn't up: `bind: Cannot assign requested address`.

IntermediateTroubleshootingsystemd services and journald
Answer

Likely causes → It binds to a specific IP that isn't configured yet when the service starts.

Diagnose →

journalctl -b -u myapp
systemctl list-dependencies myapp --after | grep network
systemctl is-enabled NetworkManager-wait-online systemd-networkd-wait-online

Fix → Add After=network-online.target and Wants=network-online.target, and make sure the matching wait-online service is enabled. Alternatively, bind to 0.0.0.0, or allow binding to absent addresses with net.ipv4.ip_nonlocal_bind=1 (useful for VIPs).

Prevent → Prefer network-online.target for services that bind to specific addresses.

All Linux questions Roadmap: Linux

More on systemd services and journald