Node.js SequelizeConnectionError:服务器不支持SSL连接
我正在尝试将我的项目与PostgreSQL连接,但显示此错误。请帮帮我 我已经安装了Postgres.app和GUI PgAdminNode.js SequelizeConnectionError:服务器不支持SSL连接,node.js,postgresql,express,ssl,sequelize.js,Node.js,Postgresql,Express,Ssl,Sequelize.js,我正在尝试将我的项目与PostgreSQL连接,但显示此错误。请帮帮我 我已经安装了Postgres.app和GUI PgAdmin Unhandled rejection SequelizeConnectionError: The server does not support SSL connections at /Users/inamur/Documents/Project/project-api/node_modules/sequelize/lib/dialects/po
Unhandled rejection SequelizeConnectionError: The server does not support SSL connections
at /Users/inamur/Documents/Project/project-api/node_modules/sequelize/lib/dialects/postgres/connection-manager.js:186:20
at Connection.connectingErrorHandler (/Users/inamur/Documents/Project/project-api/node_modules/pg/lib/client.js:203:14)
at Connection.emit (events.js:223:5)
at Connection.EventEmitter.emit (domain.js:475:20)
at Socket.<anonymous> (/Users/inamur/Documents/Project/project-api/node_modules/pg/lib/connection.js:90:21)
at Object.onceWrapper (events.js:313:26)
at Socket.emit (events.js:223:5)
at Socket.EventEmitter.emit (domain.js:475:20)
at addChunk (_stream_readable.js:309:12)
at readableAddChunk (_stream_readable.js:290:11)
at Socket.Readable.push (_stream_readable.js:224:10)
at TCP.onStreamRead (internal/stream_base_commons.js:181:23)
这是连接文件
const sequelize = new Sequelize(process.env.DB_LINK, {
dialect: 'postgres',
protocol: 'postgres',
dialectOptions: {
ssl: {
require: 'true'
}
}
});
你没有正确使用选项 只需进行以下更改:
const sequelize = new Sequelize(process.env.DB_LINK, {
dialect: 'postgres',
protocol: 'postgres',
dialectOptions: {
ssl: true,
native:true
}
});
用于是否使用本机库的本机标志。在“pg”的情况下——将此设置为true将允许SSL支持,默认值为false 我已经解决了这个问题
const sequelize = new Sequelize(process.env.DB_LINK, {
dialect: 'postgres',
protocol: 'postgres',
dialectOptions: {}, //removed ssl
});
更改数据库链接
DB_LINK='postgres://root:root@localhost:5432/SCROLL001'
建议在生产应用程序中使用SSL进行连接。您可以继续使用SSL连接,同时通过以下方式在本地绕过SSL连接:
const sequelize=new sequelize(process.env.DB_链接{
方言:“postgres”,
方案:“博士后”,
ssl:process.env.DB\u启用\u ssl,
选择:{
ssl:process.env.DB_ENABLE_ssl&&{
要求:正确
}
}
});
您的数据库是否需要SSL连接>@prabhjotsinghkaint是的感谢您的努力,但它对我不起作用
DB_LINK='postgres://root:root@localhost:5432/SCROLL001'