Nginx 502 Bad Gateway with PHP-FPM: Causes and Fixes
A 502 page tells you nothing. It means Nginx asked PHP-FPM for a response and either...
Developer tools
Paste JSON to see exactly what json_decode() gives you, as PHP array code or print_r() output. Or paste a PHP array and get json_encode() output with the flags you choose.
Converted in your browser. Nothing is uploaded.
Choose json_decode (JSON → PHP) or json_encode (PHP → JSON) and paste your input. It converts as you type.
For decoding, choose arrays or stdClass objects and PHP code or print_r(). For encoding, tick the JSON_* flags you use.
Copy or download the result, or Swap to convert it back. The line at the bottom is the matching PHP code.
json_decode($json, true) returns associative arrays. Without it (or with false), JSON objects become stdClass objects, accessed as $data->name instead of $data['name'].
A PHP array becomes a JSON list only when its keys are 0, 1, 2, … in order. Any other keys (strings, gaps, a different order) give a JSON object. Use array_values() to get a list.
By default json_encode writes / as \/ and non-ASCII characters as \u00e9. Add JSON_UNESCAPED_SLASHES and JSON_UNESCAPED_UNICODE to keep them as they are.
Arrays in [] or array() syntax, strings, numbers, true, false and null, nested as deep as you like. A full statement like $data = [...]; or return [...]; works too. Variables, constants and function calls can't be evaluated in the browser.
A 502 page tells you nothing. It means Nginx asked PHP-FPM for a response and either...
You defined a scheduled task, deployed, and nothing happens. No error, no log line, no email....
Last updated: 9 November 2026. See the update log at the end.The classic Laravel deployment bug...
We use cookies to improve your experience and analyze traffic. By continuing, you agree to our Privacy Policy.