Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

karamqubsi's avatar

Valet linux & wsl2

Hello everyone, I'd like to hear your thoughts about using valet linux on windows with wsl2

I tried that last week, and clearly this will not work out of the box, but I managed to get it working by:

  • Updating dns settings in wsl network adapter with the wsl instance local IP ( name server records for dnsmasq) ( automated)
  • adding generated valet cert to windows, ( to make it trusted locally ) ( still manual)
  • updating dnsmasq configs to allow connections from the host windows computer ( automated)

As mentioned I managed to automate part of the process, especially updating nameserver , as wsl will reset dns records in its adapter at every restart of your computer, so I managed to create a task to update that automatically.

Anyway, have you tried valet linux and wsl before ?, do you think there will be other problems ? I know the valet linux maintainer mentioned they don't support wsl, but after trying it and automating mentioned parts I found it easy to use on windows so far.

is there anything else that I'm missing here ?

0 likes
2 replies
LaryAI's avatar
Level 58

Using Valet Linux on Windows with WSL2 can be a bit tricky, but it is possible to make it work. Here are the steps you can follow:

  1. Update DNS settings in the WSL network adapter with the WSL instance's local IP. This can be done by modifying the name server records for dnsmasq. You mentioned that you have already automated this step, which is great.

  2. Add the generated Valet certificate to Windows to make it trusted locally. This step is still manual and needs to be done each time. You can follow these steps to add the certificate:

    • Open the certificate manager on Windows by pressing Win + R and typing certlm.msc.
    • Navigate to "Trusted Root Certification Authorities" > "Certificates".
    • Right-click and choose "All Tasks" > "Import".
    • Select the generated Valet certificate and follow the import wizard.
  3. Update dnsmasq configs to allow connections from the host Windows computer. This step can also be automated.

By following these steps, you have managed to automate most of the process. However, it's important to note that Valet Linux does not officially support WSL. So, there might be other problems that you could encounter while using it. It's always a good idea to keep an eye on the official documentation or community forums for any updates or workarounds.

If you have any further questions or need assistance with specific issues, feel free to ask.

Tray2's avatar

I would suggest installing Linux on a virutal machine instead, or use Laravel Sail (Docker), rather than dabble with wsl2 and windows.

This is a guide for ubuntu and nginx, just be aware that you need to change to at least php8 and use the latest version of ubuntu.

https://www.howtoforge.com/tutorial/ubuntu-laravel-php-nginx/

1 like

Please or to participate in this conversation.