Skip to main content

TUN device errors and troubleshooting

TUN device errors usually occur when the required network module is missing or not configured correctly.

A
Written by Adine
Updated over 2 weeks ago

Kernel TUN/TAP support (OpenVZ and similar environments)

Some environments (such as OpenVZ) require explicit configuration to allow containers to use the TUN/TAP device.

Make sure the TUN module is loaded on the host system:

lsmod | grep tun

If it is not loaded:

sudo modprobe tun

To ensure it loads on reboot, add it to your system configuration (e.g. /etc/modules or equivalent for your distribution).

Common issues

1. /dev/net/tun missing or permission denied

Check device:

ls -l /dev/net

If the device is missing or has incorrect permissions, recreate it:

sudo rm /dev/net/tun  
sudo mknod /dev/net/tun c 10 200
sudo chmod 666 /dev/net/tun

2. Operation not permitted

Error:

Cannot create TUN device file node: operation not permitted

This usually means:

  1. You are not running with sufficient privileges

  2. The environment restricts device creation

Ensure you are using sudo and that your environment allows TUN devices.

3. Docker cannot access TUN device

If running in Docker, expose the device:

--device /dev/net/tun:/dev/net/tun

or in docker-compose:

devices:
- /dev/net/tun:/dev/net/tun

4. Module not found

Error:

modprobe: FATAL: Module tun not found

This indicates the TUN module is missing from your kernel.

Try:

  1. Rebooting the system

  2. Updating or reinstalling kernel modules

Check if the module exists:

find /lib/modules -iname tun\.*

If it is missing, your kernel may not support TUN.


Notes

  1. TUN issues are typically caused by missing modules or restricted environments

  2. VPS or container-based setups may require additional configuration

  3. Restart your node after applying changes

Did this answer your question?