I would like to connect to Postgres using Sequelize over Unix socket (not over localhost
).
Postgres is configured to accept Unix socket connections from user pgdba
. All works from command line with psql
. So the Pg side is correctly configured.
I can't seem to find Sequelize configuration though to support Unix sockets. Closest I could find was for mysql, which I've adapted for Pg, but doesn't seem to work:
var sequelizeConfig = {
dialect: 'postgres',
dialectOptions: {
socketPath: '/home/pgdba/data/5432/.s.PGSQL.5432',
}
port: 5432
};
var sequelize = new Sequelize('fooDb', 'pgdba', 'passwd', sequelizeConfig);
The error I'm getting when starting the app:
Unable to connect to the database: +23ms { [SequelizeConnectionError: pg_hba.conf rejects connection for host "127.0.0.1", user "pgdba", database "fooDb"]
name: 'SequelizeConnectionError',
message: 'pg_hba.conf rejects connection for host "127.0.0.1", user "pgdba", database "fooDb"',...
Apparently sequelize is still trying to go over localhost
instead of the Unix socket and the pg_hba.conf
is correctly rejecting it, as is configured. Is there a way to configure Sequelize for Postgres and Unix socket?
Using Sequelize 3.14.2 on Node v5.1.0 and Postgresql 9.5.0beta2.