RTNETLINK answers: File exists
Fixes wg-quick failing with RTNETLINK answers: File exists when bringing up a WireGuard interface. Use when the address or route wg-quick wants to add is already present. Covers bringing the interface down cleanly first. Not for key errors or missing config files.
RTNETLINK answers: File exists
TL;DR: the address or route wg-quick wants to add is already on the interface from an earlier run. Bring the interface down first with wg-quick down wg0, confirm it is gone, then bring it up again.
RTNETLINK answers: File existsSteps
- Take the interface down cleanly:
sudo wg-quick down wg0Expected: no output, and ip link show wg0 reports the device does not exist.
- If it is still there, remove the leftover address by hand:
sudo ip link delete wg0Expected: ip link show wg0 finds nothing.
- Bring it up again:
sudo wg-quick up wg0Expected: the interface comes up with no RTNETLINK complaint, and wg show lists your peers.
When this applies
wg-quick upafter a previousuphalf-succeeded or was killed- the interface was created manually with
ip link addand then wg-quick ran - Address lines duplicated across config files
When it doesnt
wg-quick: 'wg0' already exists— that is the interface-level twin of this errorKey is not the correct length or format— a key problem, not an address one- no route to the peer — that is routing, not this
Compatibility
wireguard-tools wg-quick on Linux.
Other phrasings
RTNETLINK answers: File exists wg-quick upwireguard File exists on up
Why it happens
wg-quick is a script that adds addresses and routes one by one. It does not check first whether they already exist, so any leftover from a crashed or manual setup makes the kernel refuse the duplicate.
Edge cases
- If
wg-quick downsays the interface is not defined, the config name and interface name may differ; match them. - NetworkManager or systemd-networkd fighting over the same interface can recreate the conflict; pick one manager.