我想使用Sequelize over Unix socket(不是localhost
)连接到Postgres。
Postgres配置为接受来自用户pgdba
的Unix套接字连接。所有工作都来自命令行psql
。所以Pg方面配置正确。
我似乎无法找到Sequelize配置,但支持Unix套接字。我能找到的最近的是mysql,我已经适应了Pg,但似乎不起作用:
var sequelizeConfig = {
dialect: 'postgres',
dialectOptions: {
socketPath: '/home/pgdba/data/5432/.s.PGSQL.5432',
}
port: 5432
};
var sequelize = new Sequelize('fooDb', 'pgdba', 'passwd', sequelizeConfig);
启动应用时我遇到的错误:
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"',...
显然,sequelize仍然试图超越localhost
而不是Unix套接字而pg_hba.conf
正确地拒绝它,正如配置的那样。有没有办法为Postgres和Unix socket配置Sequelize?
在Node v5.1.0和Postgresql 9.5.0beta2上使用Sequelize 3.14.2。