Error: connect ECONNRESET
See original GitHub issueI 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:
- Created 6 years ago
- Reactions:1
- Comments:10 (1 by maintainers)
Top GitHub Comments
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.
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:
-> figure out if something is messing around with your network (-settings), like VMs, Firewalls etc., this is probably the cause of the problem.