Add following lines to /opt/homebrew/etc/php/8.3/php-fpm.d/www.conf: env['PGGSSENCMODE'] = disable
env['LC_ALL'] = C
Then restart PHP.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hey everyone,
I've been facing an issue with my Laravel application lately. Whenever it interacts with certain MongoDB models, I encounter a 502 Bad Gateway error from Nginx. Upon checking the error log, I found the following error message:
*3 kevent() reported about a closed connection (54: Connection reset by peer) while reading response header from upstream, client: 127.0.0.1, server: api.localhost, request: "POST /auth/validateUserForLogin HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "api.localhost"
Interestingly, the issue only arises when I access the application through the Nginx port (api.localhost/xx/yy/zz). However, when I use php artisan serve to access the Laravel's port (127.0.0.1:8000/xx/yy/zz), everything works perfectly fine.
I suspect there might be an issue with Nginx and PHP-FPM, but I'm having trouble pinpointing the exact cause. I can't recall making any significant changes that could have triggered this error.
Could someone please help me troubleshoot this issue? Thanks in advance!
Please or to participate in this conversation.