Error: read ECONNRESET

I updated max to 50 and haven’t any ECONNRESETs in about 2 months.

I am using mongodb with meteor in dev mode and i am receiving this error

Are you using SQL at all?

no SQL, only mongodb

I’ve only studied this in the context of SQL, so I don’t know why that error would come up with just Mongo. Is it possible your server needs more RAM?

I have enough ram on server, I am not sure how can I debug meteor? Is there any tool or something which can tell me the metrics for performance, slow queries or script or some sort for exceptions or errors being occured?

In my experience with PostGres, ECONNRESET is an error that occurs during the connection from your app server to your database server. So, it’s not an error that takes place in Meteor.

I just did Google searches for “mongodb econnreset” and “mongodb retry after econnreset”, and found a number of discussions, including:

So adding this to Meteor server should solve my problem?

# serving the flash policy file
net = require("net")

net.createServer((socket) =>
  //just added
  socket.on("error", (err) =>
    console.log("Caught flash policy server socket error: ")
    console.log(err.stack)
  )

  socket.write("<?xml version=\"1.0\"?>\n")
  socket.write("<!DOCTYPE cross-domain-policy SYSTEM \"http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd\">\n")
  socket.write("<cross-domain-policy>\n")
  socket.write("<allow-access-from domain=\"*\" to-ports=\"*\"/>\n")
  socket.write("</cross-domain-policy>\n")
  socket.end()
).listen(843)

That doesn’t look like the answer to me. Changing your cross-domain policy may be a security risk and is unlikely to be be related to econnreset errors in this case.

I am not sure what can I do here, my server crashes randomly after few days, i don’t have any stack trace or way to find out what is going wrong

I don’t know if meteor provide any tool or something which can show me the metrics for performance, slow queries or script or some sort for exceptions or errors being occured in the server, there should be something

If you are hosted with meteor: https://apm.meteor.com/

Or else: https://montiapm.com

I used them, but this error is not being logged anywhere in the tool, the cpu and ram usage is also normal… Not sure what to do here

That’s what this was like when I was debugging it. It was in the communication between the app server and the database server. It was very tough to find any logs about it. Where is your MongoDB hosted?

My mongodb is hosted on the same sever in the same app, I am in the development mode right now, so I run meteor run command to launch the server app

Very good. Are you doing the devops, i.e. are you the one who maintains the server?

Yes I am the one maintaining server, it is hosted on AWS EC2 instance on Ubuntu 20 LTS

Check my post from Sep '22 above. I got some excellent advice from AWS tech support about this.

What seems to have worked for me with Postgres, was to retry after errors like this. There may be a way to do this with MongoDB as well. Here’s a possibly relevant link – I haven’t read it yet: