systemd unit: use network-online.target instead?

Author: KlaaktuCreated Sep 28, 2026Updated Sep 28, 2026

TLDR: Change this

After=network.target 

to this

After=network-online.target
Wants=network-online.target

A while back when I used ss-rust, it would frequently fail to start at boot due to not being able to bind to IP, but fine when manually restarted:

systemd[1]: Started Shadowsocks-Rust Server Service.
ssservice[408]:  INFO shadowsocks server 1.24.0 build 2026-07-03T13:17:33.553871632+00:00
ssservice[408]: server aborted with Cannot assign requested address (os error 99)
systemd[1]: [email protected]: Main process exited, code=exited, status=70/SOFTWARE
systemd[1]: [email protected]: Failed with result 'exit-code'.

Because I bind to public IP to avoid having ss-rust server listening on every interface (e.g. lo, wireguard, tunnel-broker):

{
  "servers": [
    {
      "address": (public ip here),
      "port": 8388,
      "method": "2022-blake3-aes-256-gcm",
      "password": (redacted)
    }
  ]
}

And it fails because the server starts too early: https://github.com/shadowsocks/shadowsocks-rust/blob/0ff649e9a6174b1c18f7c43457bfe1da2afc4ad9/debian/shadowsocks-rust-server%40.service#L10 Explanation on network.target and network-online.target: https://systemd.io/NETWORK_ONLINE/

network.target indicates that the network management stack has been started. Ordering after it has little meaning during start-up: whether any network interfaces are already configured when it is reached is not defined.

network-online.target is a target that actively waits until the network is “up”, where the definition of “up” is defined by the network management software. Usually it indicates a configured, routable IP address of some kind. It is an active target, meaning that it may be pulled in by the services requiring the network to be up, for example network server software should generally not pull this in (since server software generally is happy to accept local connections even before any routable network interface is up). Its primary purpose is network client software that cannot operate without network.

An example of "online" in systemd-networkd:

# 10-ethernet.network
[Link]
RequiredForOnline=routable
RequiredFamilyForOnline=any

Currently all local & server units use After=network.target, but the below is more common (example):

After=network-online.target
Wants=network-online.target

After to order itself after the target, Wants to try starting the network (still starts the service if it fails).

I think for most common usages of ss-rust, you'd want the network to be up, instead of using ss-server locally / without network. So it's more correct to use network-online.target instead, even tho 0.0.0.0 would bypass the issue.

Source: shadowsocks/shadowsocks-rust