WSL2 now supports connecting Localhost from Windows 10 applications
The localhost feature has now been added back to WSL2, and you can connect directly to Docker, NPM or other services running locally on the system via Localhost.
Windows 10 Insider build 18945 has just been released by Microsoft with many noticeable improvements, including Windows Subsystem for Linux version 2 (WSL2) that has been integrated with support for seamless connectivity. Directly, Windows 10 applications with WSL2 applications via localhost.
- Live Tiles will really go into oblivion if the Windows 10 20H1 Start Menu looks great like this
Localhost has now been added back to WSL2
When WSL2 was released with the first version, the tool no longer supported the ability to connect to Linux WSL2 servers from Windows 10 applications using localhost addresses. Therefore, in case you want to connect to the WSL2 application from your Windows applications, you will have to find the IP address assigned to the running Linux distribution and connect to it as an alternative.
As for the version of Windows 10 Insider build 18945, the localhost feature has now been added back to WSL2, and you can connect directly to Docker, NPM or other services running locally on the system through Localhost. This task can be performed using the command nc as shown in the example below.
- Appeared to design Microsoft's new Action Center, the corners are more elegant and modern
Connect via Localhost
With the 're-export' of the localhost feature, users can now fully enjoy the benefits from the increase in performance of WSL2, while still easily accessible to any Linux server. Which they are running.
Link servers to 0.0.0.0 so that localhost works
Some users said they had trouble activating the localhost feature in WSL2 because their server is bound to 127.0.0.1.
The engineer responsible for WSL program manager Craig Loewen stated in a post of the WSL2 error message on the blog that in order for localhost to work, the server needs to be able to access all IP addresses, and therefore limited to 0.0.0.0. Originally written by Craig Loewen as follows:
"Can you check which IP address your php object is bound to? I suspect that it only accepts connections from localhost (127.0.0.1), while also requiring acceptability. The connections come from all IP addresses (for example, link it to 0.0.0.0) so you will need to run the command: php -S 0.0.0.0:8000
'.
For example, users have reported that they cannot let PHP work on localhost with the php -S localhost: 8000
command. This may be because the HOSTS file maps localhost to a specific loopback 127.0.0.1 address and therefore this feature will not work.
- Microsoft releases a new Windows 10 update, Microsoft Edge will be hidden if you install Edge Chromium
Distribution server file WSL2 (WSL2 File Hosts File)
When users bind PHP with 0.0.0.0, use the php -S 0.0.0.0:8000
command, the localhost connection will most likely work properly.
You should read it
- Microsoft will release Linux 'genuine' Linux kernel with Windows 10 WSL
- How to mount a Linux file system using WSL2 on Windows 10
- How to Run Linux GUI Applications with WSL2 on Windows
- What is localhost?
- How are Linux kernel updates distributed on Windows Update?
- How to update from WSL to WSL 2 in Windows 10
- What is localhost? What is differenthost compared to 127.0.0.1?
- How to install Windows Subsystem for Linux 2 on Windows 10
- Instructions for installing WordPress on localhost - Part 2
- Summary of Microsoft Build 2019: Windows Terminal, Microsoft Edge ... is there anything else worth noting?
- Instructions for installing Windows Linux Subsystem on Windows 10
- Why is Localhost's IP address 127.0.0.1?
Maybe you are interested
Latest Sharkbite Code and how to enter Code Sharkbite A critical flaw in Internet Explorer forced Microsoft to release patches for Windows 7 There is evidence that confirms the existence of a fifth force, which can reverse the physics we still know The necessary notes when buying a gaming laptop The easiest way to connect speakers to TVs 5 Google Sheets features you should know