Fix "Cannot open TUN/TAP dev /dev/net/tun" (LXC, Docker, VPS)
"Cannot open TUN/TAP dev /dev/net/tun" means your VPN can't reach the TUN device. On a Proxmox LXC, pass /dev/net/tun to the container. In Docker, add --device /dev/net/tun and NET_ADMIN. On a VPS, load the tun module. Exact commands for each.
Cannot open TUN/TAP dev /dev/net/tun means the VPN can't reach the kernel's TUN device. Your VPN config is almost never the problem. The fix depends on where it runs:
- Proxmox LXC: pass the device to the container with
pct set <CTID> --dev0 /dev/net/tun, then stop and start the container. - Docker: run the container with
--cap-add=NET_ADMIN --device /dev/net/tun. - VPS or bare metal: load the module with
modprobe tun. If that fails, the provider has TUN disabled.
The details for each case are below. The same fix applies to the variants of this error: No such file or directory (errno=2), Operation not permitted (errno=1), Unable to open /dev/net/tun, Tailscale's CreateTUN("tailscale0") failed, and "the system does not have the tun device available".
What /dev/net/tun is
/dev/net/tun is a character device (major 10, minor 200) that lets a program create virtual network interfaces: TUN for IP packets, TAP for Ethernet frames. OpenVPN, Tailscale, ZeroTier, OpenConnect, gluetun and userspace WireGuard (wireguard-go, boringtun) all open it to create their tun0, tailscale0 or wg0 interface.
Kernel WireGuard is the exception: wg-quick with the in-kernel module creates its interface without /dev/net/tun. So if WireGuard works but OpenVPN doesn't, that's why.
The error has three possible causes:
- The device node doesn't exist in this environment (container without access, module not loaded).
- It exists, but the process isn't allowed to use it (missing capability or cgroup rule).
- The host kernel or the VPS provider doesn't offer TUN at all.
Step 1: check the device
Run this where the VPN runs (inside the container or VM):
ls -l /dev/net/tun
A working system shows a character device with 10, 200:
crw-rw-rw- 1 root root 10, 200 Nov 11 09:00 /dev/net/tun
If you get No such file or directory, go to the section for your environment. If the file exists but the VPN still says Operation not permitted, it's a permission or capability problem, which is usually Docker or LXC.
Fix for Proxmox LXC containers
Unprivileged containers (the Proxmox default) don't get /dev/net/tun. You don't need to make the container privileged. Since Proxmox VE 8.1 you can pass a device into an unprivileged container, and since 8.2 there's a button for it. This is also what Tailscale's LXC guide recommends.
In the web UI: select the container, open Resources, click Add > Device Passthrough, enter /dev/net/tun as the device path, and click Add.
Or on the Proxmox host shell (replace 105 with your container ID):
pct set 105 --dev0 /dev/net/tun
If dev0 is already used for another device, use --dev1, --dev2 and so on.
Then shut the container down and start it again (a restart from inside isn't enough):
pct shutdown 105 && pct start 105
pct exec 105 -- ls -l /dev/net/tun
Proxmox 7 or older configs
On versions without the Device Passthrough option, add these two lines to /etc/pve/lxc/<CTID>.conf on the host:
lxc.cgroup2.devices.allow: c 10:200 rwm
lxc.mount.entry: /dev/net/tun dev/net/tun none bind,create=file
This also works on current Proxmox, and on unprivileged containers. The first line allows the device in the cgroup, the second bind-mounts the host's node into the container. On Proxmox 6 and older, the first line uses lxc.cgroup.devices.allow (without the 2).
Docker inside an LXC
If you run a VPN container (gluetun, Tailscale, a WireGuard image) in Docker inside an LXC, you need both: the LXC needs /dev/net/tun from the host as above, and the Docker container needs it from the LXC as in the next section. Docker in an LXC also needs nesting turned on under Options > Features.
Fix for Docker and Docker Compose
Docker containers don't get /dev/net/tun or the right to create interfaces by default. Add the device and the NET_ADMIN capability:
docker run -d --cap-add=NET_ADMIN --device /dev/net/tun:/dev/net/tun your-vpn-image
In docker-compose.yml (or compose.yaml):
services:
vpn:
image: your-vpn-image
cap_add:
- NET_ADMIN
devices:
- /dev/net/tun:/dev/net/tun
Run docker compose up -d again so the container is recreated. Restarting the old container keeps the old settings.
The host still needs /dev/net/tun itself. If the host is a VPS, check the next section first.
If you're setting up Docker from scratch, here's my Docker install script for Ubuntu.
Fix for a VPS or bare-metal Linux
On a full VM (KVM-based VPS, Proxmox VM, cloud instance) the device comes from the tun kernel module. Check and load it:
lsmod | grep -w tun
sudo modprobe tun
ls -l /dev/net/tun
On some kernels (Ubuntu's included) TUN is built in rather than a module, so lsmod may show nothing while the device still works. What matters is that /dev/net/tun exists after modprobe.
To load it at every boot:
echo tun | sudo tee /etc/modules-load.d/tun.conf
If the module is loaded but the node is missing (rare, usually in a stripped-down image), you can create it by hand:
sudo mkdir -p /dev/net
sudo mknod /dev/net/tun c 10 200
sudo chmod 666 /dev/net/tun
When modprobe fails on a VPS
If modprobe tun fails with Module tun not found or Operation not permitted, you're probably on a container-based VPS (OpenVZ or an LXC-based plan). You can't load kernel modules there. Look in your provider's control panel for a TUN/TAP switch (many have one) or ask support to enable it. If they can't, use a KVM-based plan for anything VPN-related.
Still failing? Check these
- Wrong environment. You fixed the host, but the VPN runs in a container, or the other way round. Run
ls -l /dev/net/tunin the same place the VPN runs. - Container not restarted. LXC config changes need a full stop and start. Docker needs the container recreated.
- Read-only or nodev mount. If
/devis mounted withnodev, the node exists but can't be opened. Checkmount | grep /dev. - SELinux or AppArmor. On RHEL-based hosts check
ausearch -m avc -ts recent, on Ubuntudmesg | grep -i apparmor. - No TUN option at all. Tailscale can run in userspace networking mode (
tailscaled --tun=userspace-networking), which doesn't need/dev/net/tun, at the cost of not creating a real interface.
If you run the VPN in a full Proxmox VM instead of a container, none of this applies: VMs have their own kernel and /dev/net/tun works out of the box. While you're there, install the QEMU guest agent.
My take
Don't make an LXC privileged just to get a VPN running. Device passthrough gives the container exactly one device and keeps everything else locked down. For a fresh setup I'd go with kernel WireGuard in a VM or on the host, which avoids /dev/net/tun entirely. I covered that in my WireGuard VPN setup guide.
FAQ
What does "Cannot open TUN/TAP dev /dev/net/tun: No such file or directory" mean?
The TUN device node doesn't exist where OpenVPN is running. In a container, pass /dev/net/tun from the host. On a VM or bare metal, run modprobe tun.
What does "Operation not permitted" mean with /dev/net/tun?
The device exists, but the process isn't allowed to use it. In Docker, add --cap-add=NET_ADMIN and --device /dev/net/tun. In an LXC, allow the device with Device Passthrough or the c 10:200 rwm cgroup rule.
Do I need a privileged LXC container for a VPN?
No. On Proxmox 8.1 and newer, pass /dev/net/tun to an unprivileged container with Device Passthrough or pct set <CTID> --dev0 /dev/net/tun. Tailscale, OpenVPN and gluetun all work that way.
Does WireGuard need /dev/net/tun?
Kernel WireGuard doesn't. Userspace implementations like wireguard-go and boringtun do, and so do many WireGuard Docker images when the host has no WireGuard module.
Can I create /dev/net/tun manually?
Yes, with mknod /dev/net/tun c 10 200, but only if the kernel supports TUN and the container or VM is allowed to use the device. If the host doesn't provide TUN, the node exists but opening it still fails.