DEV Community

Cover image for Find the IP address of your WSL instance
Adrien
Adrien

Posted on

10 3

Find the IP address of your WSL instance

In Windows, I'm exclusively using WSL2 for development purposes. But sometimes, it's nice to have a GUI to do some works. For example, you are using a DB engine running in Ubuntu via WSL2 but you'd like to read your data in a nice way. When you find out how it works, it's simple.

Well, I did the digging for you and I'll show you how it works (whatever the WSL version you're using).

Check your WSL instances

For various reasons, you might have more than one WSL instances on your machine. For example, using docker will set up some depending on your uses. We need to find if this is our case. If it is, then we need to check which one is the default one and change it to the one we are interested in.

Make sure to run these commands in a PowerShell terminal.

List all the instances:

    PS C:\Users\adrien> wsl -l -v
      NAME                   STATE           VERSION
    * docker-desktop-data    Stopped         2
      Ubuntu                 Running         2
      docker-desktop         Stopped         2
Enter fullscreen mode Exit fullscreen mode

As we can see, I have 3 instances of WSL. Since Docker is not running at the time, it shows as Stopped. The * shows the default instance which is not the one we are interested in. We want Ubuntu.

If this is not your case, meaning you only have one, you can skip the rest and go to "Find the IP address".

Change the default instance:

    PS C:\Users\adrien> wsl --set-default "Ubuntu"
    PS C:\Users\Plouf> wsl -l -v
      NAME                   STATE           VERSION
    * Ubuntu                 Running         2
      docker-desktop         Stopped         2
      docker-desktop-data    Stopped         2
Enter fullscreen mode Exit fullscreen mode

Smooth.

Find the IP address

Now, that's gonna be simple. Run this command:

    PS C:\Users\adrien> wsl hostname -I
    172.24.72.193
Enter fullscreen mode Exit fullscreen mode

EZ.

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (6)

Collapse
 
zippcodder profile image
Deon Rich •

Thanks!

Collapse
 
agiboire profile image
Adrien •

You're welcome! 🙌

Collapse
 
spyshow profile image
jihad khorfan •

if it's returning 3 ip addresses , how can i select the first one

Collapse
 
agiboire profile image
Adrien •

You mean wsl hostname -I returns you more than one addresses?

Collapse
 
arafat877 profile image

yes, it returns multiple IP addresses

Thread Thread
 
agiboire profile image
Adrien •

Do you have a default instance set?

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more