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: read ECONNRESET

See original GitHub issue

Hi brianc, this is my first Bug report, so please don’t blame me for bad style:)

I have an issue with loosing connections. This happens after upgrading to node v0.10.1. I used v.8x? before and it worked. I am developing with Windows 8.

Maybe this happens because the Garbage Collector was modified in the new release? I wrote a simple mocha test that shows the problem. var pg = require(‘pg’);

describe('pg', function(){
  this.timeout(65000);
  describe('connection', function() {
    it("should throw no error for 1 min", function(testDone) {

      pg.on("error", function(e){
        //"Error: read ECONNRESET" is thrown for me after 30sec
        testDone(e)
      });

      pg.connect("tcp://postgres:1234@localhost/postgres", function(err, client, done){
        client.query("select 'something'", function(err, result){
          done();
          if (err) return testDone (err);

          setTimeout(function(){
            testDone();
          }, 60000);
        });
      })
    });
  });
})

Debugging this lead me to the assumption, that it is caused by the garbage collector, that is trying to destroy the tcp socket used by the database, but maybe I am completly wrong with this.

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:18 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
reinertcommented, May 16, 2017

I still get this error when trying to connect in Windows 7 x64.

here’s the log:

acquire client begin
dispense() clients=1 available=0 info
createResource() - creating obj - count=1 min=0 max=10 verbose
connecting new client
client connection error: { Error: read ECONNRESET
    at exports._errnoException (util.js:1034:11)
    at TCP.onread (net.js:580:26) code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' }
acquire client. error: { Error: read ECONNRESET
    at exports._errnoException (util.js:1034:11)
    at TCP.onread (net.js:580:26) code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' }
pg.connect failed: Error: read ECONNRESET
dispense() clients=0 available=0 info
0reactions
ivanriccommented, Oct 19, 2016

Hello boys brian forum and apologize for the inconvenience … primaremante tell but a month I’m using the “pg” package ago, I worked well … hize as stated in the documentation building a pool and applying it in the constructor configurations for connection to postgres; but then I got an error -> ECONNRESET on the console when attempting to connect to postgres and a consultation; now I am using Windows 10 x64, postgreSQL 9.5 and node v4.6.0, I would greatly appreciate some clarification’m going with this two weeks without finding answers.

This is the error console. error fetching client from pool identificasion { [Error: read ECONNRESET] code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' }

This is the code and the connection:

_bd.js_***

`var pg=require(‘pg’);

var config = {
  user: 'postgres', //env var: PGUSER
  database: 'TallerII', //env var: PGDATABASE
  password: 'postgres', //env var: PGPASSWORD
  host: 'localhost', // Server hosting the postgres database
  port: 5432, //env var: PGPORT
  max: 100, // número máximo de clientes en la pool
  idleTimeoutMillis: 30000, // how long a client is allowed to remain idle before being closed
};
var pool = new pg.Pool(config);


pool.on('error', function (err, client) {
  console.error('idle client error', err.message, err.stack)
})
    module.exports.basedatos=pool;`

*****************************_index.js_

` var express = require(‘express’); var router = express.Router();//declarando un objeto router para ser mandado a la app var session= require(‘express-session’); var pg=require(‘pg’); var bd=require(‘…/bd.js’); var pool=bd.basedatos;

router.post(‘/Usuario/identificasion’, function(req, res, next) {//aui se le asigna las rutas console.log(req.body.xlogin,‘tb’,req.body.xpassword); pool.connect(function(err, client, done) { if(err) { return console.error(‘error fetching client from pool identificasion’, err); } client.query('SELECT * FROM DATOS WHERE(login=$1 and password=$2 and estado=1) ', [req.body.xlogin,req.body.xpassword],function(err,result){ done(); if(err) { return console.error(‘Error de ejecución de consulta’, err); } var JsonR= new Object(); JsonR.status=“resp”; JsonR.valor=true; // res.json(result.rows) console.log(JsonR); res.json(JsonR)

        });
    });
    pool.on('error', function (err, client) {
        console.error('idle client error', err.message, err.stack)
    })

// res.render(‘ModalLogueo’); });`

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 >
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 >
read ECONNRESET error while using Postman f... - DevCentral
Error is below: TCL error: /Common/irule_172.29.8.1 - can't use ... Error: read ECONNRESET error while using Postman for API calls after change to...
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