Alex's Blog

Alex's Blog

Troubleshooting WSL + localhost:3000 'connection refused' issue

#wsl2#createreactapp#iphelper

Just spent an hour trying to figure out why the browser wouldn't open localhost:3000 (served by Webpack/create-react-app in WSL2).

Normally, a server running in WSL should be accessible from the Windows (host) machine without any issues.

My troubleshooting steps, roughly:

  • check /windows/system32/drivers/etc/hosts file --nothing special here...
  • check Windows firewall rules, just in case
  • shut down WSL VM with wsl --shutdown command and restart it
  • run another app in WSL using a different port -- hmm, this works...
  • change the port of the app in question in Webpack config: PORT=3006 react-scripts start -- also works... so the problem is in the specific port!
  • see if some process is holding the port 3000 in Linux: ss -tulpn
  • check if a process is holding the port in Windows: netstat -ano | findstr :3000 or Resource Monitor -> Network tab -> Listening ports -- aha! there is one!
  • find the process name by PID in the Task Manager -> Services

Turns out, the port was taken by IP Helper service (iphlpsvc).

I could not find a way to reconfigure it, and some quick research showed that it wasn't a critical service (at least in my case), so I just disabled it in the Services.


View original post and comments at dev.to →