question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: connect ECONNRESET

See original GitHub issue

I have an express server running on localhost through app.listen(). It serves images through app.get(‘imageId’). The images are read from a DB. I have a client application firing 400+ requests at the same time through http.get()

After the first 300+ requests, I get this error on the client side for each subsequent request: Error: connect ECONNRESET 127.0.0.1:8080 There is no stack or any further detail.

On the server side, I have these error handlers, but none of them print anything:

server.on('error', function(err){
    console.error('on error handler');
    console.error(err);
});
server.on('clientError', function(err){
    console.error('on clientError handler');
    console.error(err);
});
process.on('uncaughtException', function(err) {
    console.error('process.on handler');
    console.error(err);
});

My guess is that the server is not able to handle all the requests at once and it starts rejecting the connections until it frees resources, but haven’t found a way to prove it.

Is there a way to specify the number of connections on the server? Am I doing something wrong on the server side to handle the error?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

9reactions
pszabopcommented, Nov 7, 2017

Ugh, wish this were addressed somewhere. I’ve got unit tests randomly failing with ECONNRESET and the more functionality I add to the server, the higher frequency of the failures.

3reactions
Waogcommented, May 4, 2018

I had this Error too and was able to solve it after days of debugging and analysis:

my solution

For me VirtualBox (for Docker) was the Problem. I had Port Forwarding configured on my VM and the error only occured on the forwarded port.

general conclusions

The following observations may save you days of work I had to invest:

  • For me the problem only occurred on connections from localhost to localhost on one port. -> check changing any of these constants solves the problem.
  • For me the problem only occurred on my machine -> let someone else try it.
  • For me the problem only occurred after a while and couldn’t be reproduced reliably
  • My Problem couldn’t be inspected with any of nodes or expresses (debug-)tools. -> don’t waste time on this

-> figure out if something is messing around with your network (-settings), like VMs, Firewalls etc., this is probably the cause of the problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I debug error ECONNRESET in Node.js?
ECONNRESET occurs when the server side closes the TCP connection and your request to the server is not fulfilled. The server ...
Read more >
What does “Error: read ECONNRESET” mean? - Quora
It means that your application dropped it's TCP connection. For example, if you lost your wifi signal while running your app you would...
Read more >
How do I debug error ECONNRESET in Node.js?
“ECONNRESET” means the other side of the TCP conversation abruptly closed its end of the connection. This is most probably due to one...
Read more >
ECONNRESET after response · Issue #27916 · nodejs/node
This was for me a bit of surprising behavior. You can get a connection error after a response. const http = require('http') const...
Read more >
Absolutely baffled why I am getting Error: read ECONNRESET ...
Error: read ECONNRESET is a problem in Node.js. There seesm to be something wrong yout TCP connection setup. Can you share a code...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found