Fixing systemd-networkd-wait-online Service Timeouts
By default, systemd-networkd-wait-online waits for every single network interface to be fully up. However, this is rarely the desired behavior for machines with multiple adapters, often leading to slow boot times or service starts.
Defining the Problematic Scenario
After purchasing a new laptop, I set up a minimalistic Arch Linux environment similar to my desktop. Despite the setups being nearly identical, aside from a wireless driver, I noticed that starting the Docker service was significantly slower on the laptop.
I initially spent some time "playing around" with various configuration files, but I eventually reverted all changes as nothing seemed to fix the issue. I almost convinced myself that the laptop was simply slower, despite its high-end specs. Since I primarily use it for travel, I decided it wasn't worth investigating further and simply learned to live with it.
The breakthrough came after I installed a Wi-Fi dongle on my desktop as a backup connection. Suddenly, starting Docker became slow there, too. Since I hadn't updated the system and was now seeing the same behavior on a machine with two interfaces (Wireless and Ethernet), it became clear: this was a network configuration issue, not a hardware one.
Finding the Root Cause
With the cause narrowed down, my search became much more effective. I soon discovered that systemd-networkd-wait-online defaults to waiting for every interface to be fully up, with a two minute timeout.
The slowness occurred because the Docker service calls systemd-networkd-wait-online as a dependency to ensure the network is ready. However, I usually use Ethernet on my desktop while keeping the wireless interface as an inactive backup. The system was essentially waiting for a connection that I never intended to use.
The Solution
The best fix is to configure systemd-networkd-wait-online to proceed once any interface is ready, or simply to reduce the timeout.
Solution 1: Wait for Any Interface
Run the following command as root:
systemctl edit systemd-networkd-wait-online.service
Your default CLI editor will open. Paste the following snippet into the file:
[Service] ExecStart= ExecStart=/usr/lib/systemd/systemd-networkd-wait-online --any
> Note: The empty ExecStart= is necessary to clear the existing command before defining the new one.
Ensure you paste it between the commented lines as shown below:
### Editing /etc/systemd/system/systemd-networkd-wait-online.service.d/override.conf ### Anything between here and the comment below will become the contents of the drop-in file [Service] ExecStart= ExecStart=/usr/lib/systemd/systemd-networkd-wait-online --any ### Edits below this comment will be discarded
Solution 2: Reduce the Timeout
Alternatively, you can simply reduce the grace period. Run the same edit command:
systemctl edit systemd-networkd-wait-online.service
And paste this configuration to change the timeout from two minutes to ten seconds:
[Service] ExecStart= ExecStart=/usr/lib/systemd/systemd-networkd-wait-online --timeout=10
Whichever solution you choose, restart your machine (or the service) to apply the changes.