Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fixing the valet and DNS resolving in WSL2

If the local sites aren't working, or some services, these are possible fixes.

Check the /etc/resolv.conf file, it should look like this

# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
generateResolvConf = false
nameserver 172.17.48.1

The nameserver IP address can be obtained by typing in

ip r l default

Be sure to restart the wsl in powershell using wsl --shutdown, and starting up the WSL again.

Also, be sure that you've added your sites to /etc/hosts and the Windows hosts file

127.0.0.1 mysite.test

Lastly, sometimes services are acting out on WSL2, so you can just restart them like

sudo service mysql --full-restart

Or dnsmasq whichever is causing issues.

Last but not the least you can try to restart the valet using

valet restart

This should kickstart the local sites.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment