I am trying to connect my project with PostgreSQL but show this error. Please help me I have installed Postgres.app and for GUI PgAdmin.
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)
This is my .env file
JWT_SECRET='UserNews'
DB_LINK='postgres://root:root@localhost:5432/SCROLL001?ssl=true'
This is connection file.
const sequelize = new Sequelize(process.env.DB_LINK, {
dialect: 'postgres',
protocol: 'postgres',
dialectOptions: {
ssl: {
require: 'true'
}
}
});
I have solved the issue.
const sequelize = new Sequelize(process.env.DB_LINK, {
dialect: 'postgres',
protocol: 'postgres',
dialectOptions: {}, //removed ssl
});
Change the DB Link
DB_LINK='postgres://root:root@localhost:5432/SCROLL001'
You haven`t used dialectOptions correctly.
Just make the following changes:
const sequelize = new Sequelize(process.env.DB_LINK, {
dialect: 'postgres',
protocol: 'postgres',
dialectOptions: {
ssl: true,
native:true
}
});
native flag for using a native library or not.In the case of 'pg' -- set this to true will allow SSL support, default value is false. reference link
It is recommended to use SSL for connections in production applications. You can continue to use an SSL connection using while circumventing it locally using:
const sequelize = new Sequelize(process.env.DB_LINK, {
dialect: 'postgres',
protocol: 'postgres',
ssl: process.env.DB_ENABLE_SSL,
dialectOptions: {
ssl: process.env.DB_ENABLE_SSL && {
require: true
}
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With