VPNSmith
self-host-vpnINFO

WireGuard: Unable to Access Interface: Operation Not Permitted

wg-quick stops on Unable to access interface: Operation not permitted, and the usual advice is to add sudo. Often sudo is already there. The message covers four distinct causes, from a missing capability in a container to a config file the tool refuses to read, and each one has its own check.

By Eric Gerard · Founder · VPNSmith - Self-host VPN & GDPR VPS specialist4 min readPhoto via Pexels

Affiliate disclosure - This post contains Contabo affiliate links. If you grab a VPS through them, we earn a commission at no extra cost to you.

You run wg-quick up wg0 and it stops on one line:

Unable to access interface: Operation not permitted

The first answer you will find is to add sudo. Very often sudo is already there, and the command still fails, which is where most people get stuck.

What the message is reporting

Operation not permitted is EPERM, returned by the kernel when wg tries to configure the interface over netlink. The kernel was asked, and the kernel said no. That is a narrower statement than it looks, and it is worth separating from two errors people confuse it with:

  • No such device means the interface is not there. Different problem.
  • Command not found or a module error means the tooling or the kernel module is missing. Also different.

Here the tooling ran, the call was made, and permission was denied at the kernel level. So the question is not "am I root", it is "what else is gating this call".

Cause 1: you genuinely are not root

Worth eliminating in one command, because it is free:

id -u

If that is not 0 and you did not use sudo, that is your answer. If it prints 0, move on. Note that sudo wg-quick up wg0 and sudo -E wg-quick up wg0 behave differently with respect to the environment, but neither changes the capability picture below.

Cause 2: a container without CAP_NET_ADMIN

This is the common one, and sudo cannot fix it. Inside a container you can be uid 0 and still lack the capability that authorises network administration. Root in a container is not root on the host.

Check what you actually hold:

capsh --print | grep -i net_admin

No cap_net_admin in the effective set means the kernel will refuse, every time, regardless of sudo. For Docker:

docker run --cap-add NET_ADMIN --device /dev/net/tun ...

For an unprivileged LXC container, the capability alone is usually not sufficient because the tun device is not exposed; the device has to be passed through in the container configuration. If your WireGuard lives in a container by design, the containerised setup is covered separately in running WireGuard in Docker.

A chain link fence gate held shut by a wrapped chain and two padlocks, one pale yellow and one black, with dry brown weeds visible through the mesh behind
A chain link fence gate held shut by a wrapped chain and two padlocks, one pale yellow and one black, with dry brown weeds visible through the mesh behind

Cause 3: the config file the tool will not read

wg-quick reads /etc/wireguard/wg0.conf before it touches the interface. Two file level problems land near this step:

ls -l /etc/wireguard/wg0.conf

The mode should be 600 and the owner root. A world readable config holding a private key is a real problem in its own right, and wg-quick will tell you about it. A file the invoking user cannot read produces a failure earlier in the run, before any netlink call, so read the whole output rather than the last line.

chmod 600 /etc/wireguard/wg0.conf
chown root:root /etc/wireguard/wg0.conf

Cause 4: something above the kernel is saying no

If you are root, hold NET_ADMIN, and the file is clean, look at what else can return EPERM on a netlink call:

  • A security module. SELinux or AppArmor in enforcing mode can deny the operation. dmesg | tail right after the failed command is the fastest way to see a denial, because these log where the command does not.
  • A read-only or restricted /sys. Some hardened or minimal environments mount it in a way that blocks the interface setup.
  • A syscall filter. A seccomp profile that drops the relevant calls produces the same errno with no other clue.
dmesg | tail -20

If nothing appears in dmesg, cause 4 is unlikely and the answer is almost certainly cause 2.

The order to work through

  1. id -u, confirm you are 0.
  2. capsh --print | grep net_admin, confirm the capability.
  3. ls -l /etc/wireguard/wg0.conf, confirm mode 600 and root ownership.
  4. dmesg | tail -20 immediately after the failure, look for a denial.

Four commands, and they eliminate the causes in the order of how often they turn out to be the one.

Once the interface comes up

A successful wg-quick up is not the same as a working tunnel. If the interface now exists but nothing passes, you have moved on to a routing or handshake question, not a permissions one: the handshake side is covered in WireGuard handshake troubleshooting, and the address level errors that show up right after in the bad address error.

For a VPS to host all of this on, root and NET_ADMIN come as standard with a KVM instance, which is a reason to prefer one over the cheaper container based offers where exactly this problem is built in. Our notes on picking one are in the cheapest VPS for a WireGuard VPN.

★ Nuremberg GDPR datacenter · ✓ Dedicated IPv4 included · 200+ Mbps guaranteed

Self-host your VPN on your own VPS → ContaboFull root access · public IPv4 · pick your region

Frequently asked questions

Why does wg-quick say Operation not permitted when I already used sudo?
Because sudo grants root, and root is not the only thing being checked. Inside an unprivileged container the kernel still refuses the netlink call without CAP_NET_ADMIN, and under a restrictive LSM policy or a read-only /sys the same call fails for root as well. The message reports the kernel refusal, not the absence of sudo.
What does Operation not permitted actually mean here?
It is errno EPERM returned by the kernel when wg tries to configure the interface over netlink. Something in the kernel decided this process may not touch that interface, which is different from the interface not existing (that returns a no such device error instead).
How do I fix it in Docker or LXC?
Give the container NET_ADMIN and access to /dev/net/tun. For Docker that is --cap-add NET_ADMIN --device /dev/net/tun. For an unprivileged LXC container you generally need the tun device passed through in the container config, since the capability alone is not enough.
Can a wrong file permission on the config cause this?
It can produce a refusal at the same step, yes, but the wording differs by version. wg-quick warns when /etc/wireguard/wg0.conf is world readable, and a file the invoking user cannot read at all fails earlier. Check the mode is 600 and the owner is root before looking further.
Does this error mean WireGuard is not installed?
No. A missing kernel module or missing tools give different errors, typically a module not found message or a command not found. Operation not permitted means the tooling ran and the kernel declined the request.