valet: Problems with valet on fresh install of macOS Sierra, PHP7.1 Homebrew and Valet 2.0.3

Hi,

I am having an issue with getting valet to work.

I just went through and did a clean install of Sierra, Homebrew, PHP7.1 and composer (and a few other simple utilities).

I then issued composer global require laravel/valet.

I then issued a valet install which went ahead an installed nginx and dnsmasq via homebrew and then reported that valet was successfully installed.

I issued a valet start and then tried to ping foo.dev

Ping replied back

ping: cannot resolve foo.dev: Unknown host

I restarted the machine, and same thing.

I uninstalled everything, then manually installed nginx and dnsmasq through homebrew, then reinstalled valet.

Same issue.

Checking brew services list does not list dnsmasq as an active service, however ps -ax | grep dnsmasq display a process that has a time of 0:00.00 and refreshing the ps shows that dnsmasq is constantly restarting (process ID is different on each reload of ps -ax | grep dnsmasq).

The same is true for nginx.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 27 (8 by maintainers)

Most upvoted comments

Try to delete ~/.valet, /usr/local/etc/dnsmasq.conf and reinstall valet.

What happens if you also run:

sudo brew services start dnsmasq
sudo brew services start nginx

You may need to configure dnsmasq to do some logging output, and then use that to find out why it’s not routing foo.dev for you.

ALSO: what’s your Mac set to use for DNS?

  • System Preferences->Network->(Advanced button)->DNS Should be 127.0.0.1 for dnsmasq to fire properly.

I had problems with this too and finally it worked out once I have installed it with sudo sudo install valet

[EDIT: Updated .dev to .test since that’s the default now. And the relocated valet config folder]

As I posted in #115, try using the following as your ~/.config/valet/dnsmasq.conf file contents, and sudo brew services restart dnsmasq

address=/.test/127.0.0.1

#ignore resolv.conf
no-resolv
no-poll

# listen only on localhost (for dnscrypt)
listen-address=127.0.0.1
# The bind-interfaces directive instructs dnsmasq to bind only to the network interface specified in the listen-address directive, which is important for dnscrypt use
bind-interfaces
# dnscrypt-proxy is on port 53:
server=127.0.0.1#53

# The following directives prevent dnsmasq from forwarding plain names (without any dots) or addresses in the non-routed address space to the parent nameservers.
domain-needed
bogus-priv

# default is 150, or 0 = off
cache-size=0


# Logging
log-facility=/Users/my_user_name/Downloads/dnsmasq.log
log-queries


# fallback servers to use if we can't resolve using our own rules
server=1.1.1.1
server=208.67.220.222
server=208.67.220.220
#server=4.4.4.4


#domain-needed This tells dnsmasq to never pass short names to the upstream DNS servers. If the name is not in the local /etc/hosts file then “not found” will be returned.
#bogus-priv All reverse IP (192.168.x.x) lookups that are not found in /etc/hosts will be returned as “no such domain” and not forwarded to the upstream servers.
#no-resolv Do not read resolv.conf to find the servers where to lookup dns.
#no-poll Do not poll resolv.conf for changes
#server=8.8.8.8 Set one or more DNS servers to use when addresses are not local. These are open DNS servers.
#local=/example.com/ Our local domain, queries in these domains are answered from /etc/hosts or the static-hosts files.
#address=/doubleclick.net/127.0.0.1 Use this force an address for the specified domains. e.g to block adverts force doubleclck.net to localhost
#no-hosts This options stops dnsmasq using the local /etc/hosts file as a source for lookups .
#addn-hosts=/etc/dnsmasq_static_hosts.conf Force dnsmasq to use this file for lookups. It is in the same format as /etc/hosts.
#expand_hosts So we can see our local hosts via our home domain without having to repeatedly specify the domain in our /etc/hosts file.

What needs to happen is this:

  • the mac networking needs to point to the same IP and port that dnsmasq is listening on. By default this is 127.0.0.1:53
  • so system preferences needs to point DNS to 127.0.0.1 in order for anything to be directed to dnsmasq
  • as long as nothing is interrupting that flow, then all DNS lookup traffic will be sent to dnsmasq for local resolution, and then for any domains it’s not configured to serve dnsmasq will defer to 3rd party resolvers as specified by the server= entries (I recommend using 1.1.1.1, but you could use 8.8.8.8 or 4.4.4.4 or use the OpenDNS ones I gave above)

But if something in your Mac is interfering with sending DNS traffic to the IP:port that dnsmasq is listening on, then you’ll need to figure out what that is and adjust accordingly.

Like you, I’m a little surprised that a fresh macOS install is having any of these issues. 😦

Besides *.dev does not work anymore since it is a real TLD. So use something else like *.test or *.local.

This worked for me

sudo brew services restart dnsmasq