Few things derail a developer's workflow faster in 2026 than running a routine git push origin main inside Windows Subsystem for Linux 2 (WSL2) only to watch the terminal freeze indefinitely or spit out ssh: connect to host github.com port 22: Connection timed out. When you are working remotely or securing your local environment with a Virtual Private Network, virtualized network adapters frequently collide. Hyper-V's internal virtual switch (vEthernet (WSL)) and your VPN's TUN/TAP or Wintun interface often fight over routing table metrics, DNS resolution, and Maximum Transmission Unit (MTU) packet limits.
Fortunately, you do not have to compromise your operational security by disconnecting your encryption tunnel every time you commit code. Whether you are testing mobile builds via our official Android VPN app or pushing production containers from a Windows 11 workstation, learning how to troubleshoot github ssh git push wsl2 per app split tunneling will permanently harmonize your Linux subsystem and your encrypted network stack.
Why VPNs Break GitHub SSH & Git Push Inside WSL2
To fix the underlying issue, we first need to inspect what happens at Layer 3 (Network) and Layer 4 (Transport) of the OSI model when WSL2 attempts to reach GitHub while a VPN is active on the Windows host.
- vEthernet Routing Metric Collisions: By default, WSL2 operates in a NAT-based virtualized network (unless explicitly configured for Mirrored Mode in newer 2026 Windows 11 builds). When you initialize an OpenVPN (AES-256-GCM) or WireGuard session on the Windows host, the VPN client injects a new default route (
0.0.0.0/0) with the lowest interface metric. This often hijacks traffic returning from thevEthernet (WSL)adapter, dropping packets before they reach your Linux distro. - MTU Packet Fragmentation (The Hanging Git Push): Standard Ethernet frames have an MTU of 1500 bytes. WireGuard adds up to 80 bytes of cryptographic encapsulation overhead, lowering its effective MTU to 1420 bytes. However, WSL2's internal
eth0interface defaults to 1500 bytes. When you run a smallgit fetch, packets are tiny and pass through fine. When you rungit pushwith large binary objects or heavy commits, WSL2 transmits full 1500-byte packets. The VPN interface drops these oversized frames when the Don't Fragment (DF) bit is set, causing your terminal to hang right atWriting objects: 100%. - Port 22 Firewall Blocks & IP Reputation: Many corporate networks, public Wi-Fi hotspots, and aggressive ISP firewalls outright drop outbound TCP Port 22 traffic to mitigate brute-force botnets. Furthermore, if you are connected to a crowded proxy server, GitHub's automated DDoS mitigation systems may temporarily rate-limit SSH handshakes originating from that shared exit node.
💡 Pro Developer Tip: Free Daily Encrypted Testing
Need a clean, low-latency IP to test geo-distributedwebhooks or bypass local Port 22 ISP blocks? FreeVPN 724 provides 200MB of free VPN data every single day across Windows, macOS, Android, and iOS via the official WorldVPN application. Your 200MB allowance refreshes automatically every 24 hours with zero email registration and no credit card required—more than enough bandwidth for thousands of pure-text Git commits and SSH operations!
Step-by-Step: Troubleshoot GitHub SSH Git Push WSL2 Per App Split Tunneling
The cleanest architectural solution to stop WSL2 routing loops is Per-App Split Tunneling. Depending on your threat model, you can either exclude WSL2 from the VPN tunnel (so Git traffic routes directly through your physical ISP gateway) or force only your development tools through a clean VPN exit node while leaving the rest of Windows untouched.
1. Identify the Exact Executables to Split Tunnel
A common mistake developers make when attempting to troubleshoot github ssh git push wsl2 per app split tunneling is selecting wt.exe (Windows Terminal) or code.exe (VS Code) inside their VPN client's split-tunneling menu. Because Windows Terminal is merely a graphical shell, excluding it does nothing to the underlying Hyper-V virtual machine network stack.
Instead, open your Free VPN for Windows client settings, navigate to Settings > Split Tunneling > Per-App Rules, and add the following exact system binaries:
- The WSL2 Hypervisor Service:
C:\Windows\System32\wslservice.exeandC:\Windows\System32\wslhost.exe - The Virtual Machine Worker Process:
C:\Windows\System32\vmwp.exe(Crucial for NAT-mode WSL2 routing) - Windows Host OpenSSH (If using IDE Git integration):
C:\Windows\System32\OpenSSH\ssh.exe - Git for Windows Binary:
C:\Program Files\Git\mingw64\bin\git.exeandgit-remote-https.exe
Once these processes are added to your Bypass VPN (Exclude) list, restart WSL2 by opening PowerShell as Administrator and executing wsl --shutdown. Upon relaunch, your Linux environment will communicate directly with GitHub over your native interface while your browsers and other host apps remain fully encrypted.
2. Enable WSL2 Mirrored Networking Mode (2026 Best Practice)
If you want your WSL2 traffic to remain inside the encrypted VPN tunnel without suffering from NAT routing blackholes, upgrade your WSL configuration to use mirrored networking mode. This replaces the legacy Hyper-V NAT switch with a direct mirror of your Windows host interfaces, making VPN compatibility seamless.
Open PowerShell on Windows and edit (or create) your global configuration file at C:\Users\<YourUsername>\.wslconfig:
[wsl2]
networkingMode=mirrored
dnsTunneling=true
autoProxy=true
firewall=trueSave the file, run wsl --shutdown, and reopen your Ubuntu or Debian terminal. With dnsTunneling=true, WSL2 no longer relies on a brittle auto-generated /etc/resolv.conf file that breaks every time a VPN modifies your host DNS servers. If you still experience general connectivity drops across your system, check out our dedicated guide on how to Fix VPN Connected But No Internet: 7 Quick Solutions.
Diagnostic Matrix: WSL2 Git & SSH Error Resolutions
Use the technical reference table below to match your exact terminal error output with its root network cause and permanent fix.
| Terminal Error Output | Root Network Cause | VPN Protocol Impact | Immediate Technical Fix |
|---|---|---|---|
ssh: connect to host github.com port 22: Connection timed out | ISP or local firewall dropping TCP Port 22, or vEthernet route hijacking. | High on standard UDP/TCP tunnels without port forwarding. | Route SSH over HTTPS Port 443 in ~/.ssh/config or bypass wslservice.exe. |
Writing objects: 45%... (Terminal hangs indefinitely on push) | MTU packet fragmentation between WSL2 (1500) and VPN interface (1420). | Severe on WireGuard and IKEv2 due to fixed header overhead. | Lower WSL2 eth0 MTU to 1380 or 1400 via ip link. |
ssh: Could not resolve hostname github.com: Temporary failure | VPN client overwrote host DNS, breaking WSL2's /etc/resolv.conf stub. | Affects both OpenVPN and WireGuard when DNS leak protection is strict. | Enable dnsTunneling=true in .wslconfig or set static Mullvad/Cloudflare DNS. |
kex_exchange_identification: read: Connection reset by peer | DPI firewall resetting SSH handshake or exit IP flagged by GitHub abuse filter. | Occurs on congested public proxies or unencrypted networks. | Switch to a clean 10Gbps server node via the free 200MB daily VPN app. |
Fixing the "Hanging Git Push" via MTU Clamping in WSL2
If your SSH authentication succeeds (verified by running ssh -T [email protected]), yet your git push freezes whenever you push commits larger than a few kilobytes, you are dealing with an MTU mismatch. Because WireGuard encapsulates packets using ChaCha20-Poly1305 encryption, the maximum payload size shrinks.
To verify if MTU fragmentation is breaking your Git push inside WSL2, run a ping test with the "Do Not Fragment" flag set and a payload size of 1472 bytes (which equals 1500 bytes including the 20-byte IP header and 8-byte ICMP header):
ping -M do -s 1472 github.comIf you receive ping: local error: message too long, mtu=1420 (or similar packet loss), you need to lower your WSL2 interface MTU to safely clear the VPN overhead. Run the following command inside your WSL2 Linux terminal:
sudo ip link set dev eth0 mtu 1380Setting the MTU to 1380 provides a generous 120-byte buffer that easily accommodates WireGuard, OpenVPN (AES-256-GCM), and IKEv2 headers without triggering silent packet drops. To make this persistent across reboots in Ubuntu 24.04/26.04 on WSL2, add that command to your /etc/wsl.conf under the [boot] section using command = "ip link set dev eth0 mtu 1380".
Bypassing Port 22 Blocks: Route GitHub SSH Over Port 443
Sometimes the issue isn't WSL2's virtual switch, but rather the network between you and the VPN server—or the ISP governing your split-tunneled connection. Many universities, hotels, and cellular carriers throttle or block non-standard ports. (If you frequently tether your laptop to your smartphone while coding on the road, be sure to read our guide on how to Stop ISP Throttling on Mobile: Complete Free VPN Guide).
GitHub operates a dedicated SSH listener on TCP Port 443 (the standard HTTPS port) at the hostname ssh.github.com. Because no firewall can block Port 443 without breaking the entire web, routing your SSH traffic through this endpoint solves port-blocking immediately.
Inside your WSL2 terminal, open or create ~/.ssh/config and add the following block:
Host github.com
Hostname ssh.github.com
Port 443
User git
IdentityFile ~/.ssh/id_ed25519
IdentitiesOnly yes
ServerAliveInterval 30
ServerAliveCountMax 3Save the file and enforce strict permissions with chmod 600 ~/.ssh/config. Next, test the connection:
ssh -T [email protected]You should immediately receive: Hi username! You've successfully authenticated, but GitHub does not provide shell access. The addition of ServerAliveInterval 30 also ensures that stateful NAT tables inside your VPN router do not prematurely close idle SSH sessions while you are writing commit messages.
Choosing the Right VPN Server Location for Low-Latency Git Operations
When you choose to route your WSL2 development traffic through the VPN rather than bypassing it, geographic proximity and server capacity dictate how snappy your git pull and git push commands feel. SSH handshakes require multiple round-trip exchanges before a single byte of repository data is transferred.
For example, if you are a digital nomad or remote software engineer based in Southeast Asia, routing your terminal traffic through a distant European node will introduce 250ms+ of latency per keystroke and packet acknowledgment. Instead, connecting to a regional high-speed node like our encrypted Indonesia VPN server keeps round-trip times minimal while bypassing local ISP Deep Packet Inspection (DPI). Similarly, developers working across the Middle East where aggressive VoIP and port filtering are common can achieve rock-solid SSH stability by routing through an encrypted Kuwait VPN server.
While our free tier gives you 200MB of daily data—which is plenty for pushing code changes, managing SSH keys, and updating package lists—heavy workloads such as pulling multi-gigabyte Docker images inside WSL2 or cloning massive monorepos require unthrottled capacity. You can upgrade anytime to WorldVPN Premium Plans starting at just $1.12/month to unlock unlimited bandwidth, 10Gbps gigabit network speeds, and access to 200+ global server locations across Windows, macOS, Android, and iOS.
Frequently Asked Questions (FAQ)
Why does git push work on Windows PowerShell but fail inside WSL2 when my VPN is on?
Windows PowerShell uses the native host network stack, which inherits the VPN client's Wintun or TAP interface MTU (usually 1420 bytes) and DNS settings directly. WSL2 runs inside a lightweight Hyper-V virtual machine with its own virtual adapter (eth0) defaulting to a 1500-byte MTU. When WSL2 sends a 1500-byte packet during a large git push, the Windows VPN adapter drops it due to encapsulation overhead. Lowering WSL2's MTU to 1380 or enabling Mirrored Mode fixes this instantly.
Which process should I add to Per-App Split Tunneling to exclude WSL2 from my VPN?
Do not just add your terminal app (like wt.exe). You must exclude the underlying WSL2 background binaries located in C:\Windows\System32\, specifically wslservice.exe, wslhost.exe, and the Hyper-V worker process vmwp.exe. Once excluded, run wsl --shutdown in PowerShell for the new routing rules to take effect.
Is 200MB of free daily VPN data enough for GitHub SSH and Git workflows?
Yes! Source code is highly compressible plain text. When you execute git push or git pull, Git compresses objects using zlib before transmitting them over the SSH tunnel. An average commit of several hundred lines of code consumes less than 15KB to 50KB of data. With FreeVPN 724's automatic 200MB daily refresh, you can execute thousands of Git pushes and pulls every day without spending a dime.
Should I use WireGuard or OpenVPN for WSL2 development in 2026?
WireGuard is strongly recommended for WSL2 in 2026. It operates inside the kernel space (or via high-performance Wintun drivers on Windows), resulting in significantly lower CPU overhead, faster handshake recovery when switching Wi-Fi networks, and lower latency during interactive SSH sessions compared to legacy OpenVPN TCP tunnels.