I've had to set up a scheduled task[0] to update an entry in my hosts file every time WSL is assigned a new IP address, which works well enough.
[0]: https://abdus.dev/posts/fixing-wsl2-localhost-access-issue/
I know the blog post says localhost redirection “often fails” but that’s just never been the case for me, and the citation it uses is just a link to the WSL issues page rather than a specific issue.
Or I can use the IP address directly and map it to a friendly hostname, in my case `wsl` and keep working. This is done behind the scenes with a scheduled task, so when I see `localhost:PORT` doesn't work, I just retry it with `wsl:PORT`.
The reason I haven't linked to a specific issue is that there's just so many [*], and localhost sharing is still buggy and hasn't been fixed even after 2 years.
[0]: https://github.com/microsoft/WSL/issues/5298
[1]: https://github.com/microsoft/WSL/issues/7492
[2]: https://github.com/microsoft/WSL/issues/6725
[3]: https://github.com/microsoft/WSL/issues/4885
[4]: https://github.com/microsoft/WSL/issues/5439
and many more.
For future reference linking to the issues page when there’s over 1.2k issues is unhelpful to the reader, you’re better off putting that list into your blog post, or just pick one that’s the most useful like https://github.com/microsoft/WSL/issues/7492. I doubt the reader is going to trawl for every single issue to find the ones you’re talking about. It’s like saying “Google it yourself”.
I think linking to a specific issue is more useful, like you say. I'll update the post.
> It’s like saying “Google it yourself”.
Funny enough, almost all traffic is from organic searches :)
Yes that will be slow, don’t use /mnt, anything under that directly will crawl. Use /home or somewhere else and save your work there. In VSCode you can access any dir and now there’s gui support so there’s no excuse to be using /mnt now. I believe some docs on WSL do tell you this
> The WSL IP Address changes on every restart.... ALWAYS. So trying to setup a local web server for testing becomes a hassle.
That’s weird, I’ve never had any issues relating to running a web server. Listening on a port in WSL automatically exposes it on Windows. I’ve not had to configure anything when restarting etc.