Bind servers to 0.0.0.0 for localhost to work | xxxBind servers to 0.0.0.0 for localhost to work – xxx
菜单

Bind servers to 0.0.0.0 for localhost to work

七月 30, 2019 - BleepingComputer

Bind servers to 0.0.0.0 for localhost to work

With the release of the Windows 10 Insider build 18945, the Windows Subsystem for Linux version 2 now supports the ability for Windows 10 applications to connect to WSL2 apps via localhost.

When WSL2 was first released, it no longer had the ability to connect to a WSL2 Linux server from Windows 10 applications using the localhost address.

If you wanted to connect to a WSL2 app from your Windows applications, you would now have to look up the IP address assigned to the running Linux distribution and connect to that instead.

Windows 10 Insider build 18945 has now added the localhost feature to WSL2 and you can connect to your locally running Docker, NPM, or other services via Localhost. This is illustrated using the nc command in the image below.

Bind servers to 0.0.0.0 for localhost to work
Connecting via Localhost

With this feature added, users can now enjoy the benefits of the increased WSL2 performance while still being able to easily access any linux servers that they are running.

Bind servers to 0.0.0.0 for localhost to work

Some users have had issues getting the localhost feature to work in WSL2 because their servers are bound to 127.0.0.1.

WSL program manager Craig Loewen has stated in a WSL2 bug post that in order for the localhost to work, server need to be accessible to all IP address and thus bound to 0.0.0.0.

“Can you check what IP address your php instance is bound to? I suspect that it’s only accepting connections from localhost (127.0.0.1) and it needs to be able to accept incoming connections from all IP addresses (i.e: bind it to 0.0.0.0).

So you would need to run the command: php -S 0.0.0.0:8000"

For example, the user reported that they were unable to get PHP working on localhost with the php -S localhost:8000 command.

This is because the HOSTS file maps localhost to the specific 127.0.0.1 loopback address and thus the feature didn’t work.

Bind servers to 0.0.0.0 for localhost to work
WSL2 Distribution Hosts File

When the user bound PHP to 0.0.0.0, using the php -S 0.0.0.0:8000 command, the localhost connection feature worked.

Related Articles:

Windows 10 Insider Build 18945 Brings a New Cortana Experience

Windows Subsystem for Linux 2 (WSL 2) Released to Insiders

Windows 10 Insider Build 18917 Tests New Download Throttling Settings

Windows 10 Devices Using Kerberos Realms Will Fail to Start Up

Windows 10 1903 Update Blocked by Old Intel Rapid Storage Drivers

Forum Rules and Posting Guidelines

Bleeping Computer® is a community of individuals of all ages who are here to learn new information, to help each other, and to help their fellow peers. With that in mind, we ask that all members please follow these simple rules in order to create an atmosphere where everyone feels comfortable.

The rules are as follows:

Violation of any of these rules can lead to a banning of the user from our Web Site and a deletion of their account. The consequences will be determined by the Staff on a case by case basis.

When posting you agree that the administrators and the moderators of this forum have the right to modify, delete, edit or close any topic, signature, account, or profile data at any time that they see fit. If you have any questions concerning this, please do not start a new thread, but rather private message to an administrator or moderator.

contact us


Notice: Undefined variable: canUpdate in /var/www/html/wordpress/wp-content/plugins/wp-autopost-pro/wp-autopost-function.php on line 51