Access an application running in Windows from Windows Subsystem Linux (WSL)

Overview

In this post, I am going to explain how to access an application running in windows from windows subsystem Linux (WSL).

For example, let’s say you are running a Java application in windows that is listening the port 8080 and you want to curl on it from WSL like:

curl localhost:8080

In this case, we can’t access using localhost from WSL and it may show an error like:

Failed to connect to localhost port 8080: Connection refused

Solution to access an application running in Windows from Windows Subsystem Linux (WSL)

Find the local IP address of your computer. You can find it using ipconfig command. You can try it either in PowerShell or Command Prompt.

access an application running in Windows from Windows Subsystem Linux (WSL)

When you type ipconfig in your command prompt you will get something like following:

Wireless LAN adapter Local Area Connection* 3:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :

Wireless LAN adapter Local Area Connection* 4:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :

Wireless LAN adapter Wi-Fi:

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::6451:ac8e:1c66:55a5%5
   IPv4 Address. . . . . . . . . . . : 192.168.43.228
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.43.1

Since I am using my Router it shows the address provided by the router. The correct IP address of my computer is:

192.168.43.228

Now, you can access Java application running in windows from WSL like following:

curl 192.168.43.228:8080

Conclusion

In this post, we learn to access application running in Windows from Windows Subsystem Linux.

We also learn to find the IP address that our computer is using.

Thanks


Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments