4

I'm building a Sails.js app, and I set up the sails-postgresql adapter with all of my connection info and it worked fine the first time I lifted the app and created all of my tables.

Now I get this error:

error: A hook (`orm`) failed to load!
error: error: password authentication failed for user "postgres"
at Connection.parseE (/root/royaltyPayer/vigilant-disco/royaltyPayer/node_modules/sails-postgresql/node_modules/pg/lib/connection.js:540:11)
at Connection.parseMessage (/root/royaltyPayer/vigilant-disco/royaltyPayer/node_modules/sails-postgresql/node_modules/pg/lib/connection.js:367:17)
at Socket.<anonymous> (/root/royaltyPayer/vigilant-disco/royaltyPayer/node_modules/sails-postgresql/node_modules/pg/lib/connection.js:105:22)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:172:18)
at Socket.Readable.push (_stream_readable.js:130:10)
at TCP.onread (net.js:535:20)

I have already tried all of the answers posted to this question: Postgresql: password authentication failed for user "postgres"

I have made sure that my linux password and database password for user postgres are the same.

Here is the relevant line from /etc/postgresql/9.4/main/pg_hba.conf:

local   all             postgres                                peer

Here is my code in config/connections.js:

module.exports.connections = {
PostgresqlServer: {
  adapter: 'sails-postgresql',
  host: 'localhost',
  user: 'postgres',
  password: '12345',
  port:'5433',
  database: 'myDB'
}

Here is my code in config/models.js

module.exports.models = {
  connection: 'PostgresqlServer',
  migrate: 'safe'
}

I am using: Sails version 0.11.0, Postgres version 9.4, Node version 6.0.0

My permissions on the database in psql:

                                      List of databases
 Name      |  Owner   | Encoding |   Collate   |    Ctype    |     Access privileges
---------------+----------+----------+-------------+-------------+----------------------------
 myDB | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =Tc/postgres              +
           |          |          |             |             | postgres=CTc/postgres
Community
  • 1
  • 1
  • Check if it's the same issue as [Postgres password authentication fails](http://stackoverflow.com/questions/14564644) – Daniel Vérité May 06 '16 at 10:08
  • Note that `host: 'localhost'` does not correspond to `local` connection type in pg_hba.conf, it corresponds to `host` connection type with `localhost` as the address. It's not the reason of your error, though. – Daniel Vérité May 06 '16 at 10:11
  • Thanks for the comments @DanielVérité but it is not the same issue. This user was not created using pgadmin. I did try altering the validity to infinity as suggested, but I am still getting the same error. – Cameron Green May 06 '16 at 15:41
  • Another possibility is that you set the password in a different instance than the one the program tries to connect to. That might be a long shot, but you're using 5433 as the port. Generally when doing that, it's because there is another instance running on the default port (5432). – Daniel Vérité May 06 '16 at 16:03
  • I'm not sure why it's running on port 5433 (and only that port), but it is. tcp 0 0 127.0.0.1:5433 0.0.0.0:* LISTEN – Cameron Green May 06 '16 at 21:19

0 Answers0