node.js - Node.js 的 Sequelize : cannot authenticate for postgresql

标签 node.js postgresql sequelize.js

我在为 node.js 设置 sequelize 模块时遇到问题。

首先我在postgresql中设置了用户名和密码:

postgres=# CREATE USER testuser WITH PASSWORD 'test';

这是我的初始化代码:

var Sequelize = require('sequelize');
var sequelize = new Sequelize('testdb', 'testuser', 'test', {
    host: 'localhost',
    port: 5342,
    dialect: 'postgres'
});

sequelize.query('select * from mytbl').success(function(tbl){
    console.log('success');
});

但是,当我运行这段简短的代码时,出现以下错误:

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: Failed to authenticate for PostgresSQL. Please double check your settings.

我不确定我做错了什么?如果有人可以提供帮助,将不胜感激。谢谢!

最佳答案

当我将端口更改为 5432 时,此示例有效。

关于node.js - Node.js 的 Sequelize : cannot authenticate for postgresql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20703887/

相关文章:

node.js - 为什么我本应失败的超测却通过了?

javascript - d3.js 404 json 文件未找到

json - 使用 NULL 将 JSON 数组扩展为文本值

postgresql - 触发器在交易的并发可见性方面如何表现?

amazon-web-services - Cognito 在调用 Lambda 函数时返回 UnexpectedLambdaException 超时错误

mysql - Bluemix 云平台 : How to pass a value in node. js MySQL

javascript - Passport JS "Can' t 在发送后设置标题"

mysql - 如何管理数据库表中的实体重复

node.js - Sequelize 无法向 findAll 响应添加虚拟属性

javascript - 我的邮寄路线有问题吗?