Question

Occasional 502 Bad Gateway When Uploading

Hello,

I’m new to running and maintaining my own server.

I noticed that in my web app, uploading images at a fast speed (i.e. consecutively without waiting for the previous images to finish uploading) sometimes causes my web app to crash with a 502 Bad Gateway error.

Once I refresh the page after this error, everything is OK.

If I upload at normal speeds, everything is fine.

In development mode/localhost, pace of upload is never a problem.

Is this an app issue? Or a server issue? Is this caused by not having a powerful-enough server?

If this is caused by a weak server. How can I tell? Also how do I figure out what I need to upgrade Droplets to in order to prevent this issue?

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Thank you EpicCDN,

I’m actually using Node.JS and the app is a Meteor.JS app. And the uploads are happening via whatever way GraphicsMagick uses.

Could you please help me understand how to do these tasks?

  • How can I check “how many children” and “maxspareserver” are running?
  • How can I check top/htop memory I am consuming?

Also since the posting of this topic, I did upgrade. The problem happens slightly less but I it didn’t stop completely. I find that this happens especially more if I continuously upload images that are 7 to 14 mbs big at somewhat quick speeds.

If I do not wait for each upload to finish, this problem is particularly worse.

I think you need to change your php process settings, as you are using nginx I assume you are using php-fpm? check how many children, and max_spare_server are you running. You may need some tweaks.

also check with top/htop how much memory are you consuming in your droplet, is is near the top of it, you may need an upgrade, but also can be you have too many php processes running for your amount of ram available, so again you may need some tweaks there.