Server Fault Asked on December 5, 2021
I have Laravel Valet 2.1.6 installed on Mac OS 10.14.2.
nginx 1.15.8 is installed using brew.
I restarted my Mac without installing any updates or new software, and now all example.test
sites are giving a 502 error with the following showing in the /usr/local/var/log/nginx/error.log
log:
2019/01/17 20:38:47 [warn] 31277#0: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /usr/local/etc/nginx/nginx.conf:1
2019/01/17 20:38:47 [emerg] 31277#0: bind() to 0.0.0.0:443 failed (48: Address already in use)
2019/01/17 20:38:47 [emerg] 31277#0: bind() to 0.0.0.0:443 failed (48: Address already in use)
2019/01/17 20:38:47 [emerg] 31277#0: bind() to 0.0.0.0:443 failed (48: Address already in use)
2019/01/17 20:38:47 [emerg] 31277#0: bind() to 0.0.0.0:443 failed (48: Address already in use)
2019/01/17 20:38:47 [emerg] 31277#0: bind() to 0.0.0.0:443 failed (48: Address already in use)
2019/01/17 20:38:47 [emerg] 31277#0: still could not bind()
At the same time, I get the following in the /Users/Myself/.config/valet/Log/nginx-error.log
log:
2019/01/17 20:41:34 [error] 32071#0: *1 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: example.test, request: "GET / HTTP/2.0", upstream: "fastcgi://unix:/Users/Myself/.config/valet/valet.sock:", host: "example.test"
When I run ps ax -o pid,ppid,%cpu,vsz,wchan,command|egrep '(nginx|PID)'
I see this list:
PID PPID %CPU VSZ WCHAN COMMAND
32064 1 0.0 4306660 - nginx: master process /usr/local/opt/nginx/bin/nginx -g daemon off;
32065 32064 0.0 4333284 - nginx: worker process
32066 32064 0.0 4332260 - nginx: worker process
32067 32064 0.0 4333284 - nginx: worker process
32068 32064 0.0 4333284 - nginx: worker process
32069 32064 0.0 4326116 - nginx: worker process
32070 32064 0.0 4316900 - nginx: worker process
32071 32064 0.0 4368236 - nginx: worker process
32072 32064 0.0 4331236 - nginx: worker process
32073 32064 0.0 4326116 - nginx: worker process
32074 32064 0.0 4340452 - nginx: worker process
32075 32064 0.0 4333284 - nginx: worker process
32076 32064 0.0 4334308 - nginx: worker process
36815 1406 0.0 4268060 - egrep (nginx|PID)
None of the following solves the issue:
sudo killall nginx
brew services restart nginx
brew services restart php
valet restart
valet uninstall && valet install
then valet park
on the relevant dirApache is not running as a conflicting service.
I tried doing sudo /usr/local/opt/nginx/bin/nginx -g 'daemon off;'
and got this:
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:60 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:60 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:60 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:60 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:60 failed (48: Address already in use)
nginx: [emerg] still could not bind()
Running sudo lsof -i tcp:80
produces:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 42220 root 7u IPv4 0x7ac8eae7874ccb11 0t0 TCP *:http (LISTEN)
nginx 42221 Myself 7u IPv4 0x7ac8eae7874ccb11 0t0 TCP *:http (LISTEN)
nginx 42222 Myself 7u IPv4 0x7ac8eae7874ccb11 0t0 TCP *:http (LISTEN)
nginx 42223 Myself 7u IPv4 0x7ac8eae7874ccb11 0t0 TCP *:http (LISTEN)
nginx 42224 Myself 7u IPv4 0x7ac8eae7874ccb11 0t0 TCP *:http (LISTEN)
nginx 42225 Myself 7u IPv4 0x7ac8eae7874ccb11 0t0 TCP *:http (LISTEN)
nginx 42226 Myself 7u IPv4 0x7ac8eae7874ccb11 0t0 TCP *:http (LISTEN)
nginx 42227 Myself 7u IPv4 0x7ac8eae7874ccb11 0t0 TCP *:http (LISTEN)
nginx 42228 Myself 7u IPv4 0x7ac8eae7874ccb11 0t0 TCP *:http (LISTEN)
nginx 42229 Myself 7u IPv4 0x7ac8eae7874ccb11 0t0 TCP *:http (LISTEN)
nginx 42230 Myself 7u IPv4 0x7ac8eae7874ccb11 0t0 TCP *:http (LISTEN)
nginx 42231 Myself 7u IPv4 0x7ac8eae7874ccb11 0t0 TCP *:http (LISTEN)
nginx 42232 Myself 7u IPv4 0x7ac8eae7874ccb11 0t0 TCP *:http (LISTEN)
Basically the same output when I run that command for port 443.
This valet issue post suggests valet domain test
might fix it, but that didn’t help.
Tried reinstalling PHP but no luck:
Tried deleting all valet config/certificate directories, uninstalled valet again, then reinstalled and re-parked my project dir.
Tried running nginx as root:
sudo brew services stop nginx
sudo brew services start nginx
Force quitting nginx processes in network tab of Activity Monitor fixed my issue
Answered by Deepak Kapiswe on December 5, 2021
I'm guessing the real reason for this is that you ran the brew services as root in a prior installation.
sudo brew services restart nginx
And you ended up putting a LaunchAgent inside /Library/LaunchAgents and that is starting up nginx as root at startup giving you 2 instances. You can check for this in activity monitor.
Go into /Library/LaunchAgents
and remove the offending Agent, and restart.
Answered by Gazzer on December 5, 2021
This was caused by PHP 7.3.
I removed 7.3 and 2.7.0beta1 of Xdebug for 7.3.
I then did brew install [email protected]
, then installed the 2.6.1 version of Xdebug for 7.2 using pecl
.
Everything works fine now.
Answered by eComEvo on December 5, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP