# After=network.target is a shutdown directive

**URL:** https://discourse.nixos.org/t/after-network-target-is-a-shutdown-directive/81527
**Category:** Links
**Created:** [November 29, 2026, 6:26pm UTC](https://discourse.nixos.org/t/after-network-target-is-a-shutdown-directive/81527 "2026-11-29T18:26:50Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![savyajha](https://discourse.nixos.org/user_avatar/discourse.nixos.org/savyajha/32/39720_2.png) [@savyajha](https://discourse.nixos.org/u/savyajha)
#### Post date: [November 29, 2026, 6:26pm UTC](https://discourse.nixos.org/t/after-network-target-is-a-shutdown-directive/81527/1 "2026-11-29T18:26:50Z")

</div>

> **[After=network.target is a shutdown directive](https://savyasacheejha.com/posts/after-network-target/)**
>
> After=network.target is everywhere in nixpkgs, and it doesn't do what most people think it does. A quick and dirty survey of how NixOS services order themselves around the network, and a few VM tests of what that ordering actually buys you.

---

<div class="post-metadata">

### Author: ![TLATER](https://discourse.nixos.org/user_avatar/discourse.nixos.org/tlater/32/4257_2.png) [@TLATER](https://discourse.nixos.org/u/TLATER)
#### Post date: [November 30, 2026, 10:42am UTC](https://discourse.nixos.org/t/after-network-target-is-a-shutdown-directive/81527/2 "2026-11-30T10:42:55Z")

</div>

Don’t use `network-online.target` either, though, since that will force boot to be delayed until a network connection is established.

Combined with `multi-user.target` or `default.target`, this results in laptops waiting 60 seconds to start your login manager any time they’re not in range of a known wifi. Even _when_ they are in range this comes at a hefty startup delay.

The systemd manual _used_ to recommend depending on `network.target`, I’m pretty sure, since this guaranteed being able to bind on an IP address (even if this did not guarantee that anything would be able to reach that address). Wonder if this is my imagination or if something changed.

---

<div class="post-metadata">

### Author: ![savyajha](https://discourse.nixos.org/user_avatar/discourse.nixos.org/savyajha/32/39720_2.png) [@savyajha](https://discourse.nixos.org/u/savyajha)
#### Post date: [November 30, 2026, 11:09am UTC](https://discourse.nixos.org/t/after-network-target-is-a-shutdown-directive/81527/3 "2026-11-30T11:09:49Z")

</div>

I don’t think `network.target` ever promised a working IP address, right? It just meant order this service after all the various services which manage the network. They could be NetworkManager, iwd, a custom script, pppd, whatever you want. Depending on the `Type=` specified in the service file, the various network management services may only have forked and not signalled readiness when `network.target` is reached. For an IP address, any IP address, you need to have reached `network-online.target.`

In any case, I personally do not use `network.target`. I rarely deal with network-dependent services where shutting down gracefully is important.

---

<div class="post-metadata">

### Author: ![TLATER](https://discourse.nixos.org/user_avatar/discourse.nixos.org/tlater/32/4257_2.png) [@TLATER](https://discourse.nixos.org/u/TLATER)
#### Post date: [November 30, 2026, 4:28pm UTC](https://discourse.nixos.org/t/after-network-target-is-a-shutdown-directive/81527/4 "2026-11-30T16:28:22Z")

</div>

> [@savyajha](#):
>
> I don’t think `network.target` ever promised a working IP address, right?

I _thought_ it promised that at least loopback addresses can be bound to. Tbh given the documentation for `systemd.special`, it seems like it might, given that virtual devices are guaranteed to be available, and the loopback device is such a device.

And yeah, no matter what the pretty systemd page says, `network.target` _does_ actually guarantee that virtual devices are up.

Strangely, it does not however seem to guarantee that their IP setup is finished, so I think you aren’t guaranteed to be able to bind a 127 address, or even `0.0.0.0`. I don’t understand why it should not wait for that, seems like a useful synchronization primitive (and in practice, it is used like that, probably works most of the time too).

`network-online.target` OTOH used to be explicitly recommended against by the systemd docs, precisely because it covers more than just “loopback IP addresses are bindable”, and I’m fairly certain of that, too. I think something big changed within the last year or so.

---

<div class="post-metadata">

### Author: ![savyajha](https://discourse.nixos.org/user_avatar/discourse.nixos.org/savyajha/32/39720_2.png) [@savyajha](https://discourse.nixos.org/u/savyajha)
#### Post date: [November 30, 2026, 4:40pm UTC](https://discourse.nixos.org/t/after-network-target-is-a-shutdown-directive/81527/5 "2026-11-30T16:40:27Z")

</div>

If you look at the networkd code, you’ll find that nothing actually guarantees virtual devices being allocated by the time `network.target` is reached. They say “should be allocated” because in practice virtual devices are created/allocated so fast that anything ordered after `network.target` will almost definitely see them present.

Loopback is a special case because it’s set by pid1. So even if you have no network manager of any sort, loopback is always bindable.

And I don’t think the `network-online.target` advice has changed. The man page still says (and has always said as far as I remember) daemons that only serve other hosts generally shouldn’t pull it in. For servers, the robust option is neither target: bind the wildcard, or use `IP_FREEBIND` if you need a specific address.

---

<div class="post-metadata">

### Author: ![waffle8946](https://discourse.nixos.org/user_avatar/discourse.nixos.org/waffle8946/32/27221_2.png) [@waffle8946](https://discourse.nixos.org/u/waffle8946)
#### Post date: [November 30, 2026, 6:09pm UTC](https://discourse.nixos.org/t/after-network-target-is-a-shutdown-directive/81527/6 "2026-11-30T18:09:49Z")

</div>

> [@savyajha](#):
>
> For servers, the robust option is neither target: bind the wildcard, or use `IP_FREEBIND` if you need a specific address.

Sounds like LLM output, I hope you’re engaging in good faith and not using one.

---

<div class="post-metadata">

### Author: ![bme](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@bme](https://discourse.nixos.org/u/bme)
#### Post date: [November 30, 2026, 6:21pm UTC](https://discourse.nixos.org/t/after-network-target-is-a-shutdown-directive/81527/7 "2026-11-30T18:21:07Z")

</div>

Or use netlink as god intended to dynamically respond to the conditions on the box.

---

<div class="post-metadata">

### Author: ![TLATER](https://discourse.nixos.org/user_avatar/discourse.nixos.org/tlater/32/4257_2.png) [@TLATER](https://discourse.nixos.org/u/TLATER)
#### Post date: [December 1, 2026, 8:05am UTC](https://discourse.nixos.org/t/after-network-target-is-a-shutdown-directive/81527/8 "2026-12-01T08:05:23Z")

</div>

Yeah, I’m sorry, but that’s literally what I said; `0.0.0.0` _is_ the wildcard, and I was under the assumption that `network.target` guarantees it can be bound, but the `systemd.special` docs say it doesn’t.

I haven’t read the networkd code because it’s irrelevant here; what matters is the `systemd.special` documentation, because it’s a contract for distros to fulfill, not a guide to using networkd. Those targets existed long before networkd, and other network managers exist (in fact, most of my machines do not use networkd).

If the documentation says that virtual devices should be up by the time `network.target` starts, that is a contract; if the contract is fulfilled by “well that happens super quick!”, that is a potential race condition, and I’d argue a bug in the systemd docs.

What you’re saying now also directly contradicts what you said earlier:

> [@savyajha](#):
>
> For an IP address, any IP address, you need to have reached `network-online.target.`

Kinda hard to trust you as a reliable source on any of this if you’re contradicting yourself and don’t seem to understand what I’m saying, nor really the point of the target units in the first place.

---

<div class="post-metadata">

### Author: ![savyajha](https://discourse.nixos.org/user_avatar/discourse.nixos.org/savyajha/32/39720_2.png) [@savyajha](https://discourse.nixos.org/u/savyajha)
#### Post date: [December 1, 2026, 9:40am UTC](https://discourse.nixos.org/t/after-network-target-is-a-shutdown-directive/81527/9 "2026-12-01T09:40:06Z")

</div>

That’s fair, and I spoke loosely. My bad. Wildcard and loopback can be bound at any time, that’s true. What I meant was a _specific_ address which is configured by a network manager and `network.target` does not guarantee that.

On the race condition, I agree. `networkd` signals readiness before it has even sent the requests to create the netdevs afaict. Idk if it’s a bug in networkd or the docs, but I think it’s worth reporting upstream in either case.

---

<div class="post-metadata">

### Author: ![waffle8946](https://discourse.nixos.org/user_avatar/discourse.nixos.org/waffle8946/32/27221_2.png) [@waffle8946](https://discourse.nixos.org/u/waffle8946)
#### Post date: [December 1, 2026, 11:03am UTC](https://discourse.nixos.org/t/after-network-target-is-a-shutdown-directive/81527/10 "2026-12-01T11:03:17Z")

</div>

Great, we got another claude bot…

_this is clearly llm text designed to waste our time responding_, the sycophantic phrases are bog-standard stuff.
