laravel / valet

A more enjoyable local development experience for Mac.
https://laravel.com/docs/valet
MIT License
2.5k stars 690 forks source link

Getting nginx: [emerg] bind() to 127.0.0.1:80 failed (48: Address already in use) after multiple reinstallations #1075

Closed MarGul closed 3 years ago

MarGul commented 3 years ago

Clear description of your problem

I get an error on nginx after multiple tries to reinstall both laravel valet and brew. The error that I get from nginx is: nginx: [emerg] bind() to 127.0.0.1:80 failed (48: Address already in use). When I try to go to one of my sites I get ERR_CONNECTION_REFUSED probably because nginx is not running properly.

Output

When I run brew services list I get:

▶ brew services list
Name    Status  User Plist
dnsmasq unknown root /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
nginx   error   root /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
php     started root /Library/LaunchDaemons/homebrew.mxcl.php.plist

As you can see there is an error on nginx. When I run sudo /usr/local/opt/nginx/bin/nginx -g 'daemon off;' I get this output:

nginx: [emerg] bind() to 127.0.0.1:80 failed (48: Address already in use)
nginx: [emerg] bind() to 127.0.0.1:80 failed (48: Address already in use)
nginx: [emerg] bind() to 127.0.0.1:80 failed (48: Address already in use)
nginx: [emerg] bind() to 127.0.0.1:80 failed (48: Address already in use)
nginx: [emerg] bind() to 127.0.0.1:80 failed (48: Address already in use)
nginx: [emerg] still could not bind()

so it looks like there is another nginx process started somehow? When I run sudo lsof -i tcp:80 I get this:

▶ sudo lsof -i tcp:80
COMMAND   PID   USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
nginx   71557   root    6u  IPv4 0xb2e487bcf1edb7ad      0t0  TCP localhost:http (LISTEN)
nginx   71558 margul    6u  IPv4 0xb2e487bcf1edb7ad      0t0  TCP localhost:http (LISTEN)
nginx   71559 margul    6u  IPv4 0xb2e487bcf1edb7ad      0t0  TCP localhost:http (LISTEN)
nginx   71560 margul    6u  IPv4 0xb2e487bcf1edb7ad      0t0  TCP localhost:http (LISTEN)
nginx   71561 margul    6u  IPv4 0xb2e487bcf1edb7ad      0t0  TCP localhost:http (LISTEN)
nginx   71562 margul    6u  IPv4 0xb2e487bcf1edb7ad      0t0  TCP localhost:http (LISTEN)
nginx   71563 margul    6u  IPv4 0xb2e487bcf1edb7ad      0t0  TCP localhost:http (LISTEN)
nginx   71564 margul    6u  IPv4 0xb2e487bcf1edb7ad      0t0  TCP localhost:http (LISTEN)
nginx   71565 margul    6u  IPv4 0xb2e487bcf1edb7ad      0t0  TCP localhost:http (LISTEN)
nginx   71567 margul    6u  IPv4 0xb2e487bcf1edb7ad      0t0  TCP localhost:http (LISTEN)
nginx   71568 margul    6u  IPv4 0xb2e487bcf1edb7ad      0t0  TCP localhost:http (LISTEN)
nginx   71569 margul    6u  IPv4 0xb2e487bcf1edb7ad      0t0  TCP localhost:http (LISTEN)
nginx   71571 margul    6u  IPv4 0xb2e487bcf1edb7ad      0t0  TCP localhost:http (LISTEN)

If I'm doing ps aux | grep "nginx" I get this:

▶ ps aux | grep "nginx"
margul           71571   0,0  0,0  4319864   1352   ??  S    11:21pm   0:00.00 nginx: worker process
margul           71569   0,0  0,0  4314744   1368   ??  S    11:21pm   0:00.00 nginx: worker process
margul           71568   0,0  0,0  4333176   1420   ??  S    11:21pm   0:00.00 nginx: worker process
margul           71567   0,0  0,0  4313720   1340   ??  S    11:21pm   0:00.00 nginx: worker process
margul           71565   0,0  0,0  4315768   1408   ??  S    11:21pm   0:00.00 nginx: worker process
margul           71564   0,0  0,0  4325252   2024   ??  S    11:21pm   0:00.00 nginx: worker process
margul           71563   0,0  0,0  4331128   1396   ??  S    11:21pm   0:00.00 nginx: worker process
margul           71562   0,0  0,0  4331128   1360   ??  S    11:21pm   0:00.00 nginx: worker process
margul           71561   0,0  0,0  4313720   1372   ??  S    11:21pm   0:00.00 nginx: worker process
margul           71560   0,0  0,0  4321912   1388   ??  S    11:21pm   0:00.00 nginx: worker process
margul           71559   0,0  0,0  4330104   1380   ??  S    11:21pm   0:00.00 nginx: worker process
margul           71558   0,0  0,0  4320888   1408   ??  S    11:21pm   0:00.00 nginx: worker process
root             71557   0,0  0,0  4293560    612   ??  Ss   11:21pm   0:00.00 nginx: master process nginx
margul           97215   0,0  0,0  4277664    752 s001  R+   12:11am   0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox nginx

I have run out of things to try and I'm close to reinstalling MacOS which would be crazy just to get Laravel valet to work. Like I said I have tried to uninstall Laravel valet in all different ways multiple times, rebooting, stopping the nginx services, uninstalling brew.

Please if someone can point me in the right direction that would be amazing.

Diagnosis

<details>
<summary>sw_vers</summary>
<pre>ProductName:   macOS
ProductVersion: 11.4
BuildVersion:   20F71</pre>
</details>
<details>
<summary>valet --version</summary>
<pre>Laravel Valet 2.15.3</pre>
</details>
<details>
<summary>cat ~/.config/valet/config.json</summary>
<pre>{
    "tld": "test",
    "loopback": "127.0.0.1",
    "paths": []
}</pre>
</details>
<details>
<summary>cat ~/.composer/composer.json</summary>
<pre>{
    "require": {
        "laravel/installer": "^4.1",
        "squizlabs/php_codesniffer": "^3.5",
        "laravel/valet": "^2.15"
    }
}</pre>
</details>
<details>
<summary>composer global diagnose</summary>
<pre>Changed current directory to /Users/margul/.composer
Checking composer.json: WARNING
No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license.
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com oauth access: OK
Checking disk free space: OK
Checking pubkeys: 
Tags Public Key Fingerprint: 57815BA2 7E54DC31 7ECC7CC5 573090D0  87719BA6 8F3BB723 4E5D42D0 84A14642
Dev Public Key Fingerprint: 4AC45767 E5EC2265 2F0C1167 CBBB8A2B  0C708369 153E328C AD90147D AFE50952
OK
Checking composer version: OK
Composer version: 2.1.3
PHP version: 8.0.8
PHP binary path: /usr/local/Cellar/php/8.0.8_1/bin/php
OpenSSL version: OpenSSL 1.1.1k  25 Mar 2021
cURL version: 7.77.0 libz 1.2.11 ssl (SecureTransport) OpenSSL/1.1.1k
zip: extension present, unzip present</pre>
</details>
<details>
<summary>composer global outdated</summary>
<pre>Changed current directory to /Users/margul/.composer
Legend:
! patch or minor release available - update recommended
~ major release available - update possible
psr/container 1.1.1 ~ 2.0.1 Common Container Interface (PHP FIG PSR-11)</pre>
</details>
<details>
<summary>ls -al /etc/sudoers.d/</summary>
<pre>total 0
drwxr-xr-x    2 root  wheel    64  1 Jan  2020 .
drwxr-xr-x  115 root  wheel  3680 14 Jul 21:59 ..</pre>
</details>
<details>
<summary>brew config</summary>
<pre>HOMEBREW_VERSION: 3.2.2
ORIGIN: https://github.com/Homebrew/brew
HEAD: 7d37d09709b6fbd5b89b468eb0b4438ffa0fb81c
Last commit: 3 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: d985362af4928bac6445861d320cb09934097220
Core tap last commit: 38 seconds ago
Core tap branch: master
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CASK_OPTS: []
HOMEBREW_MAKE_JOBS: 12
Homebrew Ruby: 2.6.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: dodeca-core 64-bit kabylake
Clang: 12.0.0 build 1200
Git: 2.24.3 => /Library/Developer/CommandLineTools/usr/bin/git
Curl: 7.64.1 => /usr/bin/curl
macOS: 11.4-x86_64
CLT: 12.0.0.32.28
Xcode: N/A</pre>
</details>
<details>
<summary>brew services list</summary>
<pre>Name    Status  User Plist
dnsmasq unknown root /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
nginx   error   root /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
php     started root /Library/LaunchDaemons/homebrew.mxcl.php.plist</pre>
</details>
<details>
<summary>brew list --formula --versions | grep -E "(php|nginx|dnsmasq|mariadb|mysql|mailhog|openssl)(@\d\..*)?\s"</summary>
<pre>dnsmasq 2.85
nginx 1.21.1
openssl@1.1 1.1.1k
php 8.0.8_1</pre>
</details>
<details>
<summary>brew outdated</summary>
<pre></pre>
</details>
<details>
<summary>brew tap</summary>
<pre>homebrew/core
homebrew/services</pre>
</details>
<details>
<summary>php -v</summary>
<pre>PHP 8.0.8 (cli) (built: Jul 12 2021 11:13:36) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.8, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.8, Copyright (c), by Zend Technologies</pre>
</details>
<details>
<summary>which -a php</summary>
<pre>/usr/local/bin/php
/usr/local/bin/php
/usr/bin/php</pre>
</details>
<details>
<summary>php --ini</summary>
<pre>Configuration File (php.ini) Path: /usr/local/etc/php/8.0
Loaded Configuration File:         /usr/local/etc/php/8.0/php.ini
Scan for additional .ini files in: /usr/local/etc/php/8.0/conf.d
Additional .ini files parsed:      /usr/local/etc/php/8.0/conf.d/error_log.ini,
/usr/local/etc/php/8.0/conf.d/ext-opcache.ini,
/usr/local/etc/php/8.0/conf.d/php-memory-limits.ini</pre>
</details>
<details>
<summary>nginx -v</summary>
<pre>nginx version: nginx/1.21.1</pre>
</details>
<details>
<summary>curl --version</summary>
<pre>curl 7.64.1 (x86_64-apple-darwin20.0) libcurl/7.64.1 (SecureTransport) LibreSSL/2.8.3 zlib/1.2.11 nghttp2/1.41.0
Release-Date: 2019-03-27
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp 
Features: AsynchDNS GSS-API HTTP2 HTTPS-proxy IPv6 Kerberos Largefile libz MultiSSL NTLM NTLM_WB SPNEGO SSL UnixSockets</pre>
</details>
<details>
<summary>php --ri curl</summary>
<pre>curl

cURL support => enabled
cURL Information => 7.77.0
Age => 9
Features
AsynchDNS => Yes
CharConv => No
Debug => No
GSS-Negotiate => No
IDN => Yes
IPv6 => Yes
krb4 => No
Largefile => Yes
libz => Yes
NTLM => Yes
NTLMWB => Yes
SPNEGO => Yes
SSL => Yes
SSPI => No
TLS-SRP => Yes
HTTP2 => Yes
GSSAPI => Yes
KERBEROS5 => Yes
UNIX_SOCKETS => Yes
PSL => No
HTTPS_PROXY => Yes
MULTI_SSL => Yes
BROTLI => Yes
Protocols => dict, file, ftp, ftps, gopher, gophers, http, https, imap, imaps, ldap, ldaps, mqtt, pop3, pop3s, rtmp, rtsp, scp, sftp, smb, smbs, smtp, smtps, telnet, tftp
Host => x86_64-apple-darwin20.4.0
SSL Version => (SecureTransport) OpenSSL/1.1.1k
ZLib Version => 1.2.11
libSSH Version => libssh2/1.9.0

Directive => Local Value => Master Value
curl.cainfo => no value => no value</pre>
</details>
<details>
<summary>~/.composer/vendor/laravel/valet/bin/ngrok version</summary>
<pre>ngrok version 2.3.35</pre>
</details>
<details>
<summary>ls -al ~/.ngrok2</summary>
<pre>ls: /Users/margul/.ngrok2: No such file or directory</pre>
</details>
<details>
<summary>brew info nginx</summary>
<pre>nginx: stable 1.21.1 (bottled), HEAD
HTTP(S) server and reverse proxy, and IMAP/POP3 proxy server
https://nginx.org/
/usr/local/Cellar/nginx/1.21.1 (25 files, 2.2MB) *
  Poured from bottle on 2021-07-15 at 08:48:02
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/nginx.rb
License: BSD-2-Clause
==> Dependencies
Required: openssl@1.1, pcre
==> Options
--HEAD
    Install HEAD version
==> Caveats
Docroot is: /usr/local/var/www

The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that
nginx can run without sudo.

nginx will load all files in /usr/local/etc/nginx/servers/.

To have launchd start nginx now and restart at login:
  brew services start nginx
Or, if you don't want/need a background service you can just run:
  nginx
==> Analytics
install: 39,063 (30 days), 119,247 (90 days), 502,578 (365 days)
install-on-request: 38,962 (30 days), 118,979 (90 days), 498,712 (365 days)
build-error: 0 (30 days)</pre>
</details>
<details>
<summary>brew info php</summary>
<pre>php: stable 8.0.8 (bottled), HEAD
General-purpose scripting language
https://www.php.net/
/usr/local/Cellar/php/8.0.8_1 (500 files, 77.9MB) *
  Poured from bottle on 2021-07-15 at 00:03:40
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/php.rb
License: PHP-3.01
==> Dependencies
Build: httpd, pkg-config
Required: apr, apr-util, argon2, aspell, autoconf, curl, freetds, gd, gettext, glib, gmp, icu4c, krb5, libffi, libpq, libsodium, libzip, oniguruma, openldap, openssl@1.1, pcre2, sqlite, tidy-html5, unixodbc
==> Options
--HEAD
    Install HEAD version
==> Caveats
To enable PHP in Apache add the following to httpd.conf and restart Apache:
    LoadModule php_module /usr/local/opt/php/lib/httpd/modules/libphp.so

    <FilesMatch \.php$>
        SetHandler application/x-httpd-php
    </FilesMatch>

Finally, check DirectoryIndex includes index.php
    DirectoryIndex index.php index.html

The php.ini and php-fpm.ini file can be found in:
    /usr/local/etc/php/8.0/

To restart php after an upgrade:
  brew services restart php
Or, if you don't want/need a background service you can just run:
  /usr/local/opt/php/sbin/php-fpm --nodaemonize
==> Analytics
install: 49,165 (30 days), 155,771 (90 days), 633,273 (365 days)
install-on-request: 48,279 (30 days), 152,730 (90 days), 620,532 (365 days)
build-error: 0 (30 days)</pre>
</details>
<details>
<summary>brew info openssl</summary>
<pre>openssl@1.1: stable 1.1.1k (bottled) [keg-only]
Cryptography and SSL/TLS Toolkit
https://openssl.org/
/usr/local/Cellar/openssl@1.1/1.1.1k (8,071 files, 18.5MB)
  Poured from bottle on 2021-07-15 at 00:00:46
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/openssl@1.1.rb
License: OpenSSL
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /usr/local/etc/openssl@1.1/certs

and run
  /usr/local/opt/openssl@1.1/bin/c_rehash

openssl@1.1 is keg-only, which means it was not symlinked into /usr/local,
because macOS provides LibreSSL.

If you need to have openssl@1.1 first in your PATH, run:
  echo 'export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"' >> ~/.zshrc

For compilers to find openssl@1.1 you may need to set:
  export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
  export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"

==> Analytics
install: 565,099 (30 days), 1,954,553 (90 days), 8,738,361 (365 days)
install-on-request: 40,560 (30 days), 142,300 (90 days), 1,054,438 (365 days)
build-error: 0 (30 days)</pre>
</details>
<details>
<summary>openssl version -a</summary>
<pre>LibreSSL 2.8.3
built on: date not available
platform: information not available
options:  bn(64,64) rc4(16x,int) des(idx,cisc,16,int) blowfish(idx) 
compiler: information not available
OPENSSLDIR: "/private/etc/ssl"</pre>
</details>
<details>
<summary>openssl ciphers</summary>
<pre>ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-CHACHA20-POLY1305:GOST2012256-GOST89-GOST89:DHE-RSA-CAMELLIA256-SHA256:DHE-RSA-CAMELLIA256-SHA:GOST2001-GOST89-GOST89:AES256-GCM-SHA384:AES256-SHA256:AES256-SHA:CAMELLIA256-SHA256:CAMELLIA256-SHA:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-CAMELLIA128-SHA256:DHE-RSA-CAMELLIA128-SHA:AES128-GCM-SHA256:AES128-SHA256:AES128-SHA:CAMELLIA128-SHA256:CAMELLIA128-SHA:ECDHE-RSA-RC4-SHA:ECDHE-ECDSA-RC4-SHA:RC4-SHA:RC4-MD5:ECDHE-RSA-DES-CBC3-SHA:ECDHE-ECDSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:DES-CBC3-SHA</pre>
</details>
<details>
<summary>sudo nginx -t</summary>
<pre>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</pre>
</details>
<details>
<summary>which -a php-fpm</summary>
<pre>/usr/sbin/php-fpm</pre>
</details>
<details>
<summary>/usr/local/opt/php/sbin/php-fpm -v</summary>
<pre>PHP 8.0.8 (fpm-fcgi) (built: Jul 12 2021 11:13:48)
Copyright (c) The PHP Group
Zend Engine v4.0.8, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.8, Copyright (c), by Zend Technologies</pre>
</details>
<details>
<summary>sudo /usr/local/opt/php/sbin/php-fpm -y /usr/local/etc/php/8.0/php-fpm.conf --test</summary>
<pre>[15-Jul-2021 08:54:39] NOTICE: configuration file /usr/local/etc/php/8.0/php-fpm.conf test is successful</pre>
</details>
<details>
<summary>ls -al ~/Library/LaunchAgents | grep homebrew</summary>
<pre>-rw-r--r--   1 margul  staff   571 14 Jul 23:18 homebrew.mxcl.nginx.plist
-rw-r--r--   1 margul  staff   577 14 Jul 15:19 homebrew.mxcl.php.plist
-rw-r--r--   1 margul  staff   636 10 Jun  2020 homebrew.mxcl.php@7.2.plist
-rw-r--r--   1 margul  staff   636  8 Mar 17:20 homebrew.mxcl.php@7.3.plist</pre>
</details>
<details>
<summary>ls -al /Library/LaunchAgents | grep homebrew</summary>
<pre></pre>
</details>
<details>
<summary>ls -al /Library/LaunchDaemons | grep homebrew</summary>
<pre>-rw-r--r--   1 root  admin   593 15 Jul 08:33 homebrew.mxcl.dnsmasq.plist
-rw-r--r--   1 root  admin   571 15 Jul 08:33 homebrew.mxcl.nginx.plist
-rw-r--r--   1 root  admin   577 15 Jul 08:33 homebrew.mxcl.php.plist</pre>
</details>
<details>
<summary>ls -al /Library/LaunchDaemons | grep "com.laravel.valet."</summary>
<pre></pre>
</details>
<details>
<summary>ls -aln /etc/resolv.conf</summary>
<pre>lrwxr-xr-x  1 0  0  22  1 Jan  2020 /etc/resolv.conf -> ../var/run/resolv.conf</pre>
</details>
<details>
<summary>cat /etc/resolv.conf</summary>
<pre>#
# 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.
#
search Patronen
nameserver 8.8.8.8
nameserver 192.168.1.1</pre>
</details>
<details>
<summary>ifconfig lo0</summary>
<pre>lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
    options=1203<RXCSUM,TXCSUM,TXSTATUS,SW_TIMESTAMP>
    inet 127.0.0.1 netmask 0xff000000 
    inet6 ::1 prefixlen 128 
    inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 
    nd6 options=201<PERFORMNUD,DAD></pre>
</details>
<details>
<summary>sh -c 'echo "------\n/usr/local/etc/nginx/valet/valet.conf\n---\n"; cat /usr/local/etc/nginx/valet/valet.conf | grep -n "# valet loopback"; echo "\n------\n"'</summary>
<pre>------
/usr/local/etc/nginx/valet/valet.conf
---

cat: /usr/local/etc/nginx/valet/valet.conf: No such file or directory

------</pre>
</details>
<details>
<summary>sh -c 'for file in ~/.config/valet/dnsmasq.d/*; do echo "------\n~/.config/valet/dnsmasq.d/$(basename $file)\n---\n"; cat $file; echo "\n------\n"; done'</summary>
<pre>------
~/.config/valet/dnsmasq.d/tld-test.conf
---

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

------</pre>
</details>
<details>
<summary>sh -c 'for file in ~/.config/valet/nginx/*; do echo "------\n~/.config/valet/nginx/$(basename $file)\n---\n"; cat $file | grep -n "# valet loopback"; echo "\n------\n"; done'</summary>
<pre>------
~/.config/valet/nginx/*
---

cat: /Users/margul/.config/valet/nginx/*: No such file or directory

------</pre>
</details>
MarGul commented 3 years ago

Solved the issue by updating xcode (When running brew doctor make sure it says "Ready to brew"). Then I removed uninstalled brew using the command /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh)". Then I removed everything in /usr/local by doing sudo -rf /usr/local/* to make sure that I had removed everything from brew.

When this was done I reinstalled brew with the new xcode up to date and then reinstalled laravel valet again and it worked. When I run brew services list it still says error on nginx but it's working now.

▶ brew services list
Name    Status  User Plist
dnsmasq unknown root /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
nginx   error   root /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
php     started root /Library/LaunchDaemons/homebrew.mxcl.php.plist