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

jakub.kratina's avatar

Laravel Valet + dnsmasq don't work (dnsmasq status error)

Hi,

I've upgraded to Valet 2 and PHP 7.1.

When I reinstall valet and ran valet install, dnsmasq didn't start.

➜  laravel brew services list
Name                       Status  User Plist
dnsmasq                    error   root /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
elasticsearch              started wise /Users/wise/Library/LaunchAgents/homebrew.mxcl.elasticsearch.plist
...
...

dnsmasq status is error (red).

When I check ports sudo lsof -i -n -P | grep TCP, dnsmasq is there:

...
dnsmasq   31919         nobody    5u  IPv4 0xebbcb007e91d5067      0t0    TCP 192.168.0.101:53 (LISTEN)
dnsmasq   31919         nobody    7u  IPv4 0xebbcb007ea2bfc87      0t0    TCP 127.0.0.1:53 (LISTEN)
dnsmasq   31919         nobody    9u  IPv6 0xebbcb007e3cdecb7      0t0    TCP [fe80:8::d830:c1ff:fe65:f27d]:53 (LISTEN)
dnsmasq   31919         nobody   11u  IPv6 0xebbcb007dfd20c77      0t0    TCP [fe80:4::3e15:c2ff:fedb:2ae0]:53 (LISTEN)
dnsmasq   31919         nobody   13u  IPv6 0xebbcb007dfd211d7      0t0    TCP [fe80:1::1]:53 (LISTEN)
dnsmasq   31919         nobody   15u  IPv6 0xebbcb007e3cdd737      0t0    TCP [::1]:53 (LISTEN)
nginx     32053           root    6u  IPv4 0xebbcb007e91d3e77      0t0    TCP *:80 (LISTEN)
nginx     32064           wise    6u  IPv4 0xebbcb007e91d3e77      0t0    TCP *:80 (LISTEN)
nginx     32065           wise    6u  IPv4 0xebbcb007e91d3e77      0t0    TCP *:80 (LISTEN)
nginx     32066           wise    6u  IPv4 0xebbcb007e91d3e77      0t0    TCP *:80 (LISTEN)
nginx     32067           wise    6u  IPv4 0xebbcb007e91d3e77      0t0    TCP *:80 (LISTEN)

Even works ping to the test laravel app:

➜  laravel ping laravel-5.3.dev 
PING laravel-5.3.dev (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.041 ms
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.224 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.233 ms

But when I visit the url laravel-5.3.dev via the browser, I got ERR_CONNECTION_REFUSED.

dnsmasq doesn't start after restart too (brew services restart dnsmasq - even with sudo). Still the same red error status.

Don't you know, where the problem can be?

Thank you.

Jakub

0 likes
2 replies
fideloper's avatar

In your DNSMasq setting, ensure you are setting .dev to resolve to 127.0.0.1 and not just hostname localhost.

It's possible .dev domains are resolving to hostname localhost, which may be going to the ipv6 network localhost [::1] instead of ipv4 localhost 127.0.0.1.

For example, your dnsmasq.conf file:

# May have this:
address=/.dev/localhost

# But change it to this and restart dnsmasq:
address=/.dev/127.0.0.1

I haven't used valet so I'm not sure exactly what it sets up for you.

(Using "ping" may not make that totally clear. Try dig laravel-5.3.dev @127.0.0.1 or another DNS-resolving command other than ping to see what's going on with dns more explicitly).

Resolving to the localhost IP address directly may fix that.

Note that Nginx is only listening the ipv4 network, not on ipv6. (DNSMasq is listening to both).

samcarlton's avatar

For me it was that I turned on my VPN.

Spent like 5 hours to figure this out.

1 like

Please or to participate in this conversation.