[GH-ISSUE #5408] Windows: auto-recover wintun driver on ERROR_GEN_FAILURE (error 31) #11169

Open
opened 2026-08-05 01:28:46 -04:00 by saavagebueno · 2 comments
Owner

Originally created by @Vivek-Yarra on GitHub (Feb 21, 2026).
Original GitHub issue: https://github.com/netbirdio/netbird/issues/5408

Problem

On Windows 11 (especially Insider/Dev builds), the wintun kernel driver entry can become stale after Windows updates. When this happens, wintun.CreateAdapter() fails with:

failed creating tunnel interface wt0: [error creating tun device: Error creating interface: The system cannot find the file specified.]

The wintun service shows STATE: STOPPED with WIN32_EXIT_CODE: 31 (ERROR_GEN_FAILURE).

NetBird currently retries the same failing call in a loop indefinitely, never recovering.

Root Cause

The wintun kernel driver registration (HKLM\SYSTEM\CurrentControlSet\Services\wintun) becomes stale — the driver binary at \SystemRoot\System32\drivers\wintun.sys is fine, but the service entry needs to be re-registered.

Manual Fix

Running these commands as admin immediately resolves the issue:

sc.exe delete wintun
net stop NetBird
net start NetBird

On restart, NetBird re-installs the wintun driver and it loads successfully (STATE: RUNNING, exit code 0).

Proposed Fix

In client/iface/device/device_windows.go (around the create tun interface logic), detect the wintun driver failure and attempt automatic recovery before retrying:

// Pseudo-code
adapter, err := wintun.CreateAdapter(ifaceName)
if err != nil && isWintunDriverFailure(err) {
    log.Warn("wintun driver failed, attempting re-registration...")
    exec.Command("sc.exe", "delete", "wintun").Run()
    // Brief pause for cleanup
    time.Sleep(2 * time.Second)
    // Retry — wintun.CreateAdapter will re-install the driver
    adapter, err = wintun.CreateAdapter(ifaceName)
}

This would eliminate a common Windows support issue where users must manually intervene with admin commands.

Environment

  • OS: Windows 11 Build 26200.7628 (Insider Preview)
  • NetBird: v0.65.3
  • wintun: 0.14.1
  • VBS/HVCI: Enabled (status 2)
  • #4670 — WireGuard/NetBird interaction with wintun
  • #2967 — NetBird connection failure after Windows 11 updates
Originally created by @Vivek-Yarra on GitHub (Feb 21, 2026). Original GitHub issue: https://github.com/netbirdio/netbird/issues/5408 ## Problem On Windows 11 (especially Insider/Dev builds), the wintun kernel driver entry can become stale after Windows updates. When this happens, `wintun.CreateAdapter()` fails with: ``` failed creating tunnel interface wt0: [error creating tun device: Error creating interface: The system cannot find the file specified.] ``` The wintun service shows `STATE: STOPPED` with `WIN32_EXIT_CODE: 31 (ERROR_GEN_FAILURE)`. NetBird currently retries the same failing call in a loop indefinitely, never recovering. ## Root Cause The wintun kernel driver registration (`HKLM\SYSTEM\CurrentControlSet\Services\wintun`) becomes stale — the driver binary at `\SystemRoot\System32\drivers\wintun.sys` is fine, but the service entry needs to be re-registered. ## Manual Fix Running these commands as admin immediately resolves the issue: ```powershell sc.exe delete wintun net stop NetBird net start NetBird ``` On restart, NetBird re-installs the wintun driver and it loads successfully (`STATE: RUNNING`, exit code 0). ## Proposed Fix In `client/iface/device/device_windows.go` (around the `create tun interface` logic), detect the wintun driver failure and attempt automatic recovery before retrying: ```go // Pseudo-code adapter, err := wintun.CreateAdapter(ifaceName) if err != nil && isWintunDriverFailure(err) { log.Warn("wintun driver failed, attempting re-registration...") exec.Command("sc.exe", "delete", "wintun").Run() // Brief pause for cleanup time.Sleep(2 * time.Second) // Retry — wintun.CreateAdapter will re-install the driver adapter, err = wintun.CreateAdapter(ifaceName) } ``` This would eliminate a common Windows support issue where users must manually intervene with admin commands. ## Environment - **OS:** Windows 11 Build 26200.7628 (Insider Preview) - **NetBird:** v0.65.3 - **wintun:** 0.14.1 - **VBS/HVCI:** Enabled (status 2) ## Related - #4670 — WireGuard/NetBird interaction with wintun - #2967 — NetBird connection failure after Windows 11 updates
Author
Owner

@TechSupportJosh commented on GitHub (Apr 17, 2026):

Also getting this issue at the moment - would be great to get the PR merged for this 👀

<!-- gh-comment-id:4269988292 --> @TechSupportJosh commented on GitHub (Apr 17, 2026): Also getting this issue at the moment - would be great to get the PR merged for this 👀
Author
Owner

@tejaJISR commented on GitHub (Apr 19, 2026):

Will be very valuable for ease of things.

<!-- gh-comment-id:4275321330 --> @tejaJISR commented on GitHub (Apr 19, 2026): Will be very valuable for ease of things.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#11169