Skip to content

[Bug]: Nginx 502 error #1634

@JacobDelcroix

Description

@JacobDelcroix

Platform

macOS

Operating system version

macOS

System architecture

ARM64 (M1, M2, etc)

Herd Version

1.25.0

PHP Version

No response

Bug description


Bug: PHP-FPM silently crashes on certain requests while PHP CLI works fine

Environment

  • Herd version: 1.25.0
  • macOS: Darwin 25.2.0 (Apple Silicon)
  • PHP: 8.5.2 (also tested with 8.4, same issue)
  • Framework: Laravel 12 + Filament v5

Description

PHP-FPM crashes silently on certain HTTP requests (e.g., /admin/teams in Filament panel), while the same requests work
perfectly with:

  • php artisan serve
  • curl (sometimes)
  • PHP CLI / Tinker

The crash is so brutal that even register_shutdown_function() is not called, suggesting a segfault or the process being
killed.

Nginx error log

upstream prematurely closed connection while reading response header from upstream,
client: 127.0.0.1, server: basket-assistant.test, request: "GET /admin/teams HTTP/2.0",
upstream: "fastcgi://unix:/Users/xxx/Library/Application Support/Herd/herd.sock:"

Debug findings

I added detailed logging in public/index.php and a custom middleware. The request flow stops abruptly:

[16:55:45] Step 4b: Kernel resolved (mem:10MB)
[16:55:45] MW: path=admin/teams ua=Mozilla/5.0... (mem:18MB)
[16:55:45] MW: cookies=XSRF-TOKEN,coach-basket-session (mem:18MB)
[16:55:45] MW: calling next... (mem:18MB)

<-- No more logs, process killed before shutdown handler

What I tried (none worked)

  • ✅ Disabling OPcache via .user.ini: opcache.enable = 0
  • ✅ Suppressing E_DEPRECATED: error_reporting = E_ALL & ~E_DEPRECATED
  • ✅ Switching PHP version (8.4, 8.5)
  • ✅ Restarting PHP/Nginx: herd restart php && herd restart nginx
  • ✅ Clearing all caches: php artisan optimize:clear

What works

  • php artisan serve → ✅ Works perfectly
  • php -S 127.0.0.1:8888 -t public → ✅ Works perfectly
  • Docker with same codebase → ✅ Works perfectly

Reproduction

This happens on multiple Laravel projects, not just one. The crash occurs specifically when:

  1. User is authenticated (has session cookies)
  2. Request goes through Herd's PHP-FPM
  3. Request involves complex page rendering (Filament resources, not simple routes)

Simple pages like /admin (dashboard) work fine, but resource listing pages crash.

Suspected cause

The issue might be related to:

  • Herd's custom PHP extension (herd-85-arm64.so)
  • PHP-FPM worker configuration
  • Interaction between HTTP/2, sessions, and Filament's rendering

Steps to reproduce

No response

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions