Gluetun Not Found: TUN Device Docker

Abstract: Fix Gluetun TUN device error in Docker by adding NET_ADMIN capability and mounting /dev/net/tun.

Created: 2026-09-30 by
The "Gluetun not found: TUN device" error in Docker typically occurs because the container lacks the necessary Linux kernel capabilities to create virtual network interfaces. This issue often surfaces after a hardware restart when system permissions or device nodes are reset, preventing Gluetun from establishing its VPN tunnel. Resolving this requires adjusting the Docker run command or compose file to grant specific privileges and device access.

Understanding the TUN Device Requirement

Gluetun is a lightweight OpenVPN and WireGuard client that runs inside a Docker container. To function correctly, it must interact directly with the host operating system's networking stack. The TUN (Network Tunnel) device is a virtual network interface that allows the container to route traffic through the VPN provider. Without explicit permission to access this device node, the container cannot initialize the tunnel, resulting in the fatal error message.

This problem is distinct from general connectivity issues. It is specifically about the container's ability to create and manage network interfaces at the kernel level. When you see the log entry indicating the TUN device is missing or inaccessible, it means Docker has blocked the request due to security restrictions by default.

Why Hardware Restarts Trigger This

After a server reboot, the state of Linux device nodes can vary depending on how the system initializes udev rules and Docker services. If the Docker daemon starts before the necessary kernel modules are fully loaded, or if the device permissions are not reapplied correctly, Gluetun will fail to find the /dev/net/tun path. This is particularly common in environments where automatic service recovery does not account for transient device availability.

Solution 1: Updating docker-compose.yml

The most robust way to fix this issue is by modifying your docker-compose.yml configuration file. You need to explicitly add two key components: the capability to perform administrative network operations and a direct mount of the TUN device from the host.

  1. Open your docker-compose.yml file in a text editor.
  2. Locate the service definition for gluetun.
  3. Add the cap_add section with NET_ADMIN to allow network configuration changes.
  4. Include the devices section to map /dev/net/tun into the container.
services:
  gluetun:
    image: qmcg99/gluetun
    container_name: gluetun
    cap_add:
      - NET_ADMIN
    devices:
      - /dev/net/tun:/dev/net/tun:rwm
    environment:
      - TZ=Europe/London
      - VPN_SERVICE_PROVIDER=privateinternetaccess
      - VPN_TYPE=openvpn
    volumes:
      - ./config:/gluetun
    ports:
      - 8820:8820
      - 8388:8388/tcp
      - 8388:8388/udp
    restart: unless-stopped

The rwm flag stands for read, write, and mknod access, ensuring the container can create the device node if it does not exist yet. After saving the file, restart the container using docker compose up -d. Check the logs with docker logs gluetun to verify that the tunnel initialization succeeds.

Solution 2: Verifying Host Device Existence

If updating the compose file does not resolve the issue, the underlying problem may lie with the host system itself. You must ensure that the /dev/net/tun device actually exists on the host machine. Run the following command in your terminal:

ls -l /dev/net/tun

If the file is missing, you may need to load the kernel module manually. Execute sudo modprobe tun to load the module. Then, check if the device appears. In some minimal Linux distributions or custom kernels, this module might not be compiled in. If so, you may need to reinstall the kernel headers or use a different base image that includes these modules.

Additionally, check the permissions of the device node. It should typically be owned by root with group root or kvm, and permissions set to crw-rw----. If the permissions are too restrictive, Docker will be unable to access it even if mounted. Use sudo chmod 666 /dev/net/tun as a temporary test to see if this resolves the immediate blockage, though permanent fixes involve proper udev rules.

Solution 3: Checking Docker Daemon Configuration

In rare cases, the Docker daemon itself may have restrictions that prevent privileged operations. While adding cap_add is usually sufficient, some enterprise setups enforce strict seccomp profiles. If you suspect this, review your Docker daemon configuration in /etc/docker/daemon.json. Ensure that no custom seccomp profiles are blocking the mknod or cap_net_admin syscalls required by Gluetun.

You can also try running the container with elevated privileges temporarily to isolate the issue. Add --privileged to your docker run command. If the container starts successfully with this flag, the issue is definitely related to capability restrictions rather than the VPN credentials or network configuration. However, using --privileged is less secure than the targeted approach in Solution 1, so revert to the specific capabilities once verified.

Related Troubleshooting Steps

Once the TUN device is accessible, you might encounter secondary issues such as DNS leaks or routing loops. Ensure that your application containers are connected to the same Docker network as Gluetun. You can achieve this by defining a custom bridge network in your docker-compose.yml and attaching both Gluetun and your dependent services to it. This ensures all traffic flows through the encrypted tunnel correctly.

If you are migrating from a previous setup, clear any stale network configurations. Sometimes, leftover iptables rules or docker networks from failed attempts can interfere with the new TUN interface creation. Use docker network prune and iptables -F (with caution) to reset the network state if necessary. For more advanced networking scenarios involving SSH tunnels within Docker, refer to our guide on Emulated SSH Server Pinging, Traceroute Fails for Docker on Host VM which covers similar low-level network debugging techniques.

Frequently Asked Questions

Why does the TUN device disappear after a reboot?

The device node is created dynamically by the kernel when the tun module is loaded. If the module fails to load automatically during boot due to missing drivers or conflicting settings, the device will not exist. Manually loading the module with modprobe tun often restores it immediately.

Can I use WireGuard instead of OpenVPN to avoid TUN issues?

WireGuard also requires a TUN device, so it faces the same Docker permission requirements. The solution remains identical: you must still add cap_add: [NET_ADMIN] and mount /dev/net/tun regardless of the VPN protocol used.

What if my Docker container still says "Permission denied" after mounting the device?

This usually indicates that the host's SELinux or AppArmor policies are blocking access. Check your security profiles and ensure they allow Docker to access the /dev/net/tun path. You may need to adjust the security context or disable the specific restriction for that container.

Is it safe to run Gluetun with --privileged?

While --privileged grants all capabilities and removes restrictions, it exposes your host system to significant security risks. It is strongly recommended to stick to the minimal cap_add and devices configuration unless you are diagnosing a complex issue in an isolated environment.

How do I verify that Gluetun is actually routing traffic?

Connect another container to the Gluetun network and ping an external IP address. Alternatively, configure your browser or client to use Gluetun's local proxy (usually port 8820) and visit a "what is my IP" website to confirm the public IP matches your VPN provider's location.

Tags: Linux Docker

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More