WSL 2 Accessing Services Running on Windows

Iain Rough
1 min readOct 16, 2019

--

So I took the jump, updated to Windows Insider Fast Ring to allow me to access WSL 2. (what a difference compared to WSL 1) It runs fast rings around WSL 1.

I had one issue I could not connect to the MySql instance I have running on Windows. WSL 2 changed the network from bridged to NAT, so to connect I had to use my local network address.

Happy days until you change network and get a new ip…

My solution/hack:

part 1: Get IP address on windows and pass to bash script

part 2: Update host file on WSL 2

part 3: Allow script to be run without password

credit to https://dev.to/ironfroggy/wsl-tips-starting-linux-background-services-on-windows-login-3o98

part 4: Schedule with TaskScheduler every time you login

part 5: profit

--

--

Iain Rough
Iain Rough

Written by Iain Rough

Thoughts on things, not necessary unique or interesting

No responses yet