wode
By:
wode

Failed to load resource: net::ERR_CONTENT_LENGTH_MISMATCH

March 24, 2017 783 views
Node.js Ubuntu 16.04

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::ERRCONTENTLENGTH_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

1 Answer

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.

Have another answer? Share your knowledge.