I’m experiencing issues with Laravel Valet on my macOS system. When I check the logs, I see some errors related to PHP-FPM and Nginx. Here are the logs:
PHP-FPM Log:
[01-Aug-2023 09:13:04] WARNING: [pool valet] child 79760 exited on signal 11 (SIGSEGV) after 3.751510 seconds from start [01-Aug-2023 09:13:04] NOTICE: [pool valet] child 79768 started
Nginx Log
2023/08/01 08:56:36 [error] 73231#0: *28 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: gmreproducciones.test, request: "GET / HTTP/2.0", upstream: "fastcgi://unix:/Users/juliofranco/.config/valet/valet.sock:", host: "gmreproducciones.test" 2023/08/01 09:13:04 [error] 73231#0: *35 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: gmreproducciones.test, request: "GET / HTTP/2.0", upstream:
"fastcgi://unix:/Users/juliofranco/.config/valet/valet.sock:", host: "gmreproducciones.test"
System Info:
- macOS BigSur 11.7.9
- PHP version: 8.2.8 (cli)
- Valet version: Laravel Valet 4.1.3
- Laravel Framework version: 9.52.12
- Using PHP version linked in valet: [email protected]
Issue:
I’m encountering three distinct errors. First, PHP-FPM is experiencing a SIGSEGV (Segmentation fault) error, and its child process is terminating unexpectedly. Second, Nginx is showing "upstream prematurely closed connection" errors when accessing my website, resulting in a 502 Bad Gateway error. Third, I’m facing an issue with database access using Valet. Database Access Issue: When trying to access the database (PostgreSQL@14) through Valet, the website fails with the mentioned Nginx errors. However, I’ve verified that database connections work fine when testing them directly. Additionally, if I run php artisan serve within my project, the database connection is successful, and I don’t experience any issues.
Configuration: I have Valet using PHP version 8.2. My brew services list shows that dnsmasq, httpd, and postgresql@14 are running fine. However, Nginx and PHP-FPM are showing errors. My Nginx configuration seems to be pointing to the correct socket file (valet.sock) for PHP-FPM. Troubleshooting Attempted: I have restarted Valet and PHP-FPM, but the issue persists. I verified that my PHP and Laravel Valet versions are compatible. Checked Nginx configuration and logs, but couldn’t find any issues related to the errors. Reviewed the logs but couldn’t determine the root cause.
I expect Valet, PHP-FPM, and Nginx to work correctly, and the website to have successful database access without 502 Bad Gateway errors. Can someone help me identify and resolve the issues with PHP-FPM, Nginx, and database access through Valet?
2
Answers
I fall on the same problem yesterday. I am using PHP Monitor and I have provided First Aid & Services > Fix My Valet… and First Aid & Services > Restore Homebrew Permissions respectively.
Fixed. However, if it doesn’t work for you, I suggest you completely uninstall valet and reinstall it and restart your local servers.
In
/usr/local/etc/php/8.2/php-fpm.d/www.conf
after the following:Add an environment variable like this:
Then restart php. This will work even after a reboot.
Tested this working in php 8.2 and 7.4.