Why Does Caddy Proxying To A Python API Throw 502s Only During Traffic Spikes??

502nginxreverse-proxy5 replies · 102 views · started
  1. long time lurker first post lol my site has been running fine for months on Caddy proxying to a Python API... now it falls over only during traffic spikes and all visitors get this:

    restarting everything brings it back, until it doesnt. im not a full-time sysadmin, i set this up from a tutorial and it just worked. now Im staring at log files i barely understand. which log should i look at first, and what am i looking for? any ideas??

    1
  2. oh ive been there lol after reboots and deploys, teh classic causes are a socket path mismatch (fastcgi_pass unix:/run/php/... pointing at a socket name that changed), the app not being enabled at boot (systemctl enable yourapp), or a container listening on 127.0.0.1 inside Docker sooo the proxy container cant reach it. Bind to 0.0.0.0 in the container and use the service name in teh proxy config.

    3 1 helpful
  3. A 502 means the proxy reached out to teh app behind it and got a broken or no response. Read teh proxy's 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. good luck man!

    2 0 helpful
  4. is reverse-proxy even worth bothering with or should i just leave it. exact same thing happened to my gaming rig last month ?

    10 0 helpful
  5. @nadiaz420 did u ever fix it?, reading this at 2am instead of sleeping, no regrets ??

    2 0 helpful

Reply to this topic

Sign in or create an account to reply.