karuna.dev

Fixing WSL2, IPv6, and Supabase

Problem

If you happen to:

  1. try to vibe code something on your Windows PC
  2. use WSL2 because Unix
  3. 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

  1. Set WSL’s networking mode to “Mirrored”. You can use the “WSL Settings” app or manually add networkingMode=Mirrored to your .wslconfig.
  2. Restart the WSL instance: wsl --shutdown
  3. Reopen WSL: wsl
  4. Immediately run ping ipv6.google.com -i 1 -W 2 -O to 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.