valet: This site can't be reached / ERR_CONNECTION_REFUSED

Two days ago, seemingly out of nowhere, my Valet sites suddenly had all stopped working. If I try to load any of them in a browser I just get:

(Chrome) This site can’t be reached cufm.test’s server IP address could not be found.

(Firefox) We can’t connect to the server at cufm.test.

Over the past two days I’ve tried absolutely everything I could find in previous similar issues, but nothing seemed to fix it on my machine. I ultimately even wiped the entire machine and restored a Time Machine backup from last week (when things were working). But even that somehow didn’t fix the issue.

Running valet uninstall --force fails with a The process has been signaled with signal "9". error, but trying any of the fixes mentioned in #876 don’t fix that issue for me. So I’ve attempted a manual uninstall and reinstall with:

valet unsecure --all
rm -rf ~/.config/valet
composer global remove laravel/valet
brew uninstall --force php nginx dnsmasq
sudo rm -rf /usr/local/Cellar/php/7.4.12

brew update
brew upgrade
brew cleanup    (no issues)
brew doctor    (no issues)

brew install php
composer global require laravel/valet
valet install

No luck, so I decided to remove Homebrew and Composer completely and just start over from scratch:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh)"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
brew upgrade
brew install php

rm /usr/local/bin/composer
rm -rf ~/.composer
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'c31c1e292ad7be5f49291169c0ac8f683499edddcfd4e42232982d0fd193004208a58ff6f353fde0012d35fdd72bc394') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
mv composer.phar /usr/local/bin/composer

composer global require laravel/valet
valet install
cd ~/Sites
valet park

Still nothing, same issue as before. When checking the logs, ~/.config/valet/Log/nginx-error.log is empty and /usr/local/var/log/php-fpm.log shows:

NOTICE: fpm is running, pid 72876
NOTICE: ready to handle connections

Running valet uninstall --force still fails with a The process has been signaled with signal "9". error.

I’m out of ideas, but really hoping someone can point me in the right direction.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 88 (49 by maintainers)

Most upvoted comments

PSA / Reminder: A lot of Valet “issues” are caused by outdated dependencies. Running brew upgrade and composer global update at least monthly is a wise housekeeping practice.

We’re all back to normal. For anyone finding this in the future, I’m not a 100% sure what combination of changes ultimately fixed the issue, but I’m pretty sure the issue was originally caused by the installation of ExpressVPN and ultimately solved again by a fresh installation of ExpressVPN.

@drbyte thank you so much for hanging in there and being relentless in trying to track down the issue. It’s very much appreciated!

Had similar issue – after some OS updates and cleanups, reinstalling Valet / Nginx / PHP etc everything worked and then suddenly stopped working, throwing ERR_NAME_NOT_RESOLVED. This thread helped to figure out that dnsmasq might not be working properly. Removing it and installing via valet install again as suggested by @drbyte fixed the issue. Thanks!

Thanks for starting off with a thorough initial incident report. That makes providing help soooooo much easier!

Glad you got it sorted out.

nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful
nginx: [emerg] unknown directive "foobar" in /usr/local/etc/nginx/valet/valet.conf:1
nginx: configuration file /usr/local/etc/nginx/nginx.conf test failed

Yup, port 60 responds just fine:

HTTP/1.1 200 OK
Server: nginx/1.19.4
Date: Thu, 05 Nov 2020 01:10:39 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Accept-Encoding
X-Powered-By: PHP/7.4.12
X-Robots-Tag: noindex, nofollow, nosnippet, noarchive

Links to lrwxr-xr-x 1 0 0 22 21 Nov 2019 /etc/resolv.conf -> ../var/run/resolv.conf

/etc/resolv.conf:

#
# macOS Notice
#
# This file is not consulted for DNS hostname resolution, address
# resolution, or the DNS query routing mechanism used by most
# processes on this system.
#
# To view the DNS configuration used by this system, use:
#   scutil --dns
#
# SEE ALSO
#   dns-sd(1), scutil(8)
#
# This file is automatically generated.
#
domain lan
nameserver 127.0.0.1
nameserver 1.1.1.1
nameserver 1.0.0.1

Among other things, I’d be exploring:

  • brew services list - what’s it saying about dnsmasq? Should be running as root, with no errors

  • what are your system’s resolvers set to? In System Preferences, Network, Wifi, DNS, what are the DNS Servers? If 127.0.0.1 is not there or not first in the list, do you have an intentional reason?

  • ping foo.test - what’s the output

  • You said this all started “2 days ago”. What changed on your mac 2 days ago? Reboot? Software upgrades? Software installs? New apps? Removed apps?

  • does /private/etc/resolver/test exist? what’s in it? It should say nameserver 127.0.0.1 inside.

  • You could enable dnsmasq logging by creating /Users/mike/.config/dnsmasq.d/config-logging-on.conf containing:

# specify a log file location
log-facility=/Users/mike/.config/valet/Logs/dnsmasq.log
## the following line enables logging
log-queries

(delete the file or rename it without a .conf extension when you don’t need logging anymore; the file gets large fast)

  • You could delete dnsmasq and let Valet reinstall it:
sudo brew services stop dnsmasq
brew remove dnsmasq
rm -rf /usr/local/etc/dnsmasq.conf /usr/local/etc/dnsmasq.d ~/config/valet/dnsmasq.d
valet install
valet tld test
  • Advanced tip taken from a Genius Bar employee when I had a very odd networking issue (nothing would connect anywhere) that absolutely all other tactics couldn’t resolve: Go to System Preferences, Network, and in the Locations dropdown, note which one is selected currently, choose Edit, create a new one, and delete the prior one. Reboot. Sometimes this magically fixes the world. I wouldn’t do it unless you need to, but since you said you have a current reliable backup it feels safe to try.

After that, does running valet tld test solve the problem? This is valet’s default, but if part of the config for it has been damaged perhaps this might reset it.