Fixing WSL2, IPv6, and Supabase
Problem
If you happen to:
- try to vibe code something on your Windows PC
- use WSL2 because Unix
- use Supabase for a database
chances are that you have encountered this error:
connect ENETUNREACH 2600:1f16:1cd0:333a:bdd7:4c0e:6296:43a0:5432 - Local (:::0)
Why
This happens because there is a bug in the way Windows routes IPv6 packets to WSL2 and it’s been there for at least several years. The real hero who actually found this bug posted it on their blog, but only the archive link survived. Read it for more details; I am just preserving the knowledge.
Solution
- Set WSL’s networking mode to “Mirrored”. You can use the “WSL Settings” app or manually add
networkingMode=Mirroredto your.wslconfig. - Restart the WSL instance:
wsl --shutdown - Reopen WSL:
wsl - Immediately run
ping ipv6.google.com -i 1 -W 2 -Oto keep pinging an IPv6 address (forever) from within WSL so that Windows understands how to route the packets.
The author of the original investigation built a useful tool that only does this when Windows “forgets” about the correct routing but I wasn’t able to run it. withinboredom, you are an absolute legend.