502 bad gateway whenever someone uploads a big file. caddy proxying to a python api and zero clues

502nginxreverse-proxy6 replies · 354 views · started
  1. not gonna lie this is driving me nuts getting 502 Bad Gateway wehnever someone uploads a big file, and it's starting to cost us orders.

    502 Bad Gateway

    502 Bad Gateway
    nginx
    

    the setup is Caddy proxying to a Python API on a small VPS 😭 CPU graphs look normal, disk isnt full. the proxy itself is clearly alive cuz it serves teh error page. so something beihnd it is dying or not answering, but what? id appreciate a checklist from someone who has hnuted these before. detailed answers welcome, Im comfortable on teh command line. what am i doing wrong??

    rage

    5
  2. uhh what exactly does teh proxy error log say at the time of a 502?? ??

    32 0 helpful
  3. ahh right error log shows connect() failed (111: Connection refused) while connecting to upstream every time, whenever someone uploads a big file. idk what else to say tbh

    9 0 helpful
  4. @ping_works-3pl nah thats not it, whenever has nothing to do with it. wait does this also apply to 502?

    35 2 helpful
  5. ok so a 502 means the proxy reached out to teh app behind it and got a broken or no resopnse. Read the proxys error log first: sudo tail -n 100 /var/log/nginx/error.log for Nginx. connect() failed (111: Connection refused) means nothing is listening; upstream prematurely closed connection means the app crashed or killed teh request mid-way. worked for me anyway 🤷

    0 1 helpful
  6. ok so check teh app service right after a 502: systemctl status php*-fpm, systemctl status yourapp, or docker compose ps... if it shows restarts or eixted state, read its own logs with journalctl -u yourapp -n 200 or docker compose logs app. the real error lives there, not in teh proxy log. worked for me anyway 🤷

    0 2 helpful

Reply to this topic

Sign in or create an account to reply.