2

I have a sails web app in an intranet environment. An average of ~12 users are logged in at the same time. Eventually I get the classic connection refused message from sails-postgresql that lasts for at least 3 minutes, denying all http requests made to the app.

Error creating a connection to Postgresql using the following settings:
{ 
...
schema: true,
ssl: false,
adapter: 'sails-postgresql',
poolSize: 50
...
}

I either get { [Error: write ECONNRESET] code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'write' } or { [Error: write ECONNRESET] code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' }.

My PostgreSQL logs the following message: No connection could be made because the target machine actively refused it.

As you can see, my poolSize in sails.config.connections is set to 50 and my max_connections in postgresql.conf is set to 100. I'm not using this database for something else.

Is my poolsize set ok? Is it a problem from Sails or is it Postgres'?

  • I'm guessing, it is leaking connections somewhere, which gets automatically rectified by parameter [poolIdleTimeout](https://github.com/brianc/node-postgres/blob/master/lib/defaults.js#L31), but doesn't help in the long run. Probably worthwhile logging it against Sails. I wouldn't blame the `node-postgres` driver for that, it is rock-solid when it comes to connections. – vitaly-t Jun 02 '16 at 16:13

1 Answers1

0

Try increasing max_connections in postgres config file postgresql.conf, in my Ubuntu 15.04 linux it is located in this path:

/etc/postgresql/9.4/main/postgresql.conf