Question

Failed to load resource: net::ERR_CONTENT_LENGTH_MISMATCH

I am hosting an app using DO’s MEAN droplet. When I was trying to post a specific data using a POST api at the frontend (angularjs), it gives me the below error message.

Failed to load resource: net::ERR_CONTENT_LENGTH_MISMATCH Failed to load resource: the server responded with a status of 502 (Bad Gateway)

This POST api will save a picture file to the /public directory within the app according to the country folder and also it will update the data to mongodb.

The strange thing is the error only appears when i was doing a POST to one particular country with a picture uploaded. It works fine if i am just posting text data. And after the error appeared, I checked the database the data is updated, but the picture is not saved at that country’s folder. I can get do a GET to that country’s data or picture without issue.

*the POST api is not country specific

When i looked at the nginx log, it says: 2017/03/24 06:53:06 [error] 5309#5309: *66813 upstream prematurely closed connection while reading upstream, client: 175.156.60.170, s$ 2017/03/24 06:53:06 [error] 5309#5309: *66788 connect() failed (111: Connection refused) while connecting to upstream, client: 175.156$ 2017/03/24 06:53:06 [error] 5309#5309: *66788 connect() failed (111: Connection refused) while connecting to upstream, client: 175.156$ 2017/03/24 06:53:06 [error] 5309#5309: *66846 connect() failed (111: Connection refused) while connecting to upstream, client: 175.156$ 2017/03/24 06:53:06 [error] 5309#5309: *66847 connect() failed (111: Connection refused) while connecting to upstream, client: 175.156$

Could anyone tell me what is the issue and how to resolve this? Thank you


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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hi—it looks like nginx is unable to connect to your nodejs app. Make sure that it is still running and listening on the same port that nginx is configured to send requests to.