skip to Main Content

I am trying to make Valet and Local work together on Mac but with no luck. There’s probably a DNS conflict with dnsmasq.

For example I have these two sites, with the default configuration setup:

Site on Local:

local-site.local

Local is an environment optimized for setting up WordPress sites locally. I am using all the default settings. Local can be downloaded here: https://localwp.com/

Site on Valet:

valet-site.test

There’s nothing special in the Valet configuration either:

/Users/goran/.config/valet/config.json

{
    "tld": "test",
    "paths": [
        "/Users/goran/.config/valet/Sites",
        "/Users/goran/projects"
    ]
}

/Users/goran/.config/valet/dnsmasq.d/tld-test.conf

address=/.test/127.0.0.1
listen-address=127.0.0.1

Note: Both sites have different suffixes, so suffixes shouldn’t be an issue.

Scenario #1

Start both Valet and Local

Results:

  • Valet site works fine
  • Local site shows "502 Bad Gateway" error from nginx.

When I open Local it shows this error:

"There is a port conflict with this site’s domain."

This is probably returned from Valet, it probably has DNS priority over Local.

Scenario #2

Start only Local

Results:

  • Local site works fine
  • Valet site shows an error (as expected since Valet is not started). It’s interesting that this error comes from Local:

404 Site Not Found The site you requested does not have an associated
route in Local. If you continue to get this message after refreshing,
try restarting the Local site.

It looks like something is wrong with DNS setup, but I’m not sure what exactly.

4

Answers


  1. Chosen as BEST ANSWER

    I ended up with a workaround solution where you need to make sure to do things in the following steps:

    1. Make sure both Local and Valet are turned off
    2. Start Local site(s)
    3. Start Valet

    In this order Local DNSMasq will run first and Valet second. When Vale DNSMasq runs after it does not break Local changes, so this can be used as a workaround.

    In some cases you will see that sites on Local are not working (showing Valet site not found error) and in such cases you will need to do things in the following order:

    1. Stop Valet
    2. Stop Local site(s)
    3. Start Local site(s)
    4. Start Valet

    This way the resetting will configure all sites back correctly, and you can use this until you want to start/stop another site on Local. No issues on adding new sites on Valet though, since Valet DNSMasq is the one that handles sites at this moment.

    TIP1: Sometimes the port conflict issue still may appear in Local, but what you can do is to make sure is Valet is stopped and then restart Local site(s) and make sure they work first (by going into browser and checking) and after that you can start Valet.

    TIP2: Another trick when you are unable to resolve conflict by just restarting Local site (while Valet is stopped) is to create a dummy Local site that you would use just to restarting, this may trigger the restart of DNSMasq and resolve the issue.

    TIP3: You may need to wait for a 10s or so before starting Valet after Local (or just visit Local site in browser to see if it's live)


  2. This isn’t a DNS issue, as it says in the error – they’re both attempting to use the same port. It’s a port conflict, they’re likely both trying to use port 80.

    Just change one, the other, or both to use different ports.

    Login or Signup to reply.
  3. Another options is to use Local’s localhost router mode:
    enter image description here

    This would free up port 80 for the other application.

    Login or Signup to reply.
  4. I encountered the same issue too, what I did was to stop Laravel Valet using the valet stop command, then start Local.
    Once Local and my sites on Local are up, I started valet using the valet start command and I can now access my sites using valet and local.

    My domain suffix is test for valet and local for Local.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search