Skip to content

Instantly share code, notes, and snippets.

@dingo-d
Created June 12, 2021 12:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dingo-d/d9a7339ead8e0b7f2dd8fe1b849de7ed to your computer and use it in GitHub Desktop.
Save dingo-d/d9a7339ead8e0b7f2dd8fe1b849de7ed to your computer and use it in GitHub Desktop.
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