'How do I use Sequelize to connect to Heroku Postgres?
this is my configuration:
import { Sequelize } from "sequelize";
import dotenv from 'dotenv';
dotenv.config();
export const sequelize = new Sequelize(process.env.DATABASE_URL as string,
{
dialect: 'postgres',
}
)
error:
ConnectionError [SequelizeConnectionError]: no pg_hba.conf entry for host "186.194.175.39", user "xuavcbfkstvqrm", database "d3t76co8ov8vqm", SSL off
at Client._connectionCallback (d:\Projetos-VSCODE\Crud-tsnode\node_modules\sequelize\lib\dialects\postgres\connection-manager.js:189:24)
at Client._handleErrorWhileConnecting (d:\Projetos-VSCODE\Crud-tsnode\node_modules\pg\lib\client.js:305:19)
at Client._handleErrorMessage (d:\Projetos-VSCODE\Crud-tsnode\node_modules\pg\lib\client.js:325:19)
at Connection.emit (node:events:390:28)
at Connection.emit (node:domain:475:12)
at d:\Projetos-VSCODE\Crud-tsnode\node_modules\pg\lib\connection.js:114:12
at Parser.parse (d:\Projetos-VSCODE\Crud-tsnode\node_modules\pg-protocol\src\parser.ts:104:9)
at Socket.<anonymous> (d:\Projetos-VSCODE\Crud-tsnode\node_modules\pg-protocol\src\index.ts:7:48)
at Socket.emit (node:events:390:28)
at Socket.emit (node:domain:475:12) {
parent: error: no pg_hba.conf entry for host "186.194.175.39", user "xuavcbfkstvqrm", database "d3t76co8ov8vqm", SSL off
at Parser.parseErrorMessage (d:\Projetos-VSCODE\Crud-tsnode\node_modules\pg-protocol\src\parser.ts:369:69)
at Parser.handlePacket (d:\Projetos-VSCODE\Crud-tsnode\node_modules\pg-protocol\src\parser.ts:188:21)
at Parser.parse (d:\Projetos-VSCODE\Crud-tsnode\node_modules\pg-protocol\src\parser.ts:103:30)
at Socket.<anonymous> (d:\Projetos-VSCODE\Crud-tsnode\node_modules\pg-protocol\src\index.ts:7:48)
at Socket.emit (node:events:390:28)
at Socket.emit (node:domain:475:12)
at addChunk (node:internal/streams/readable:315:12)
at readableAddChunk (node:internal/streams/readable:289:9)
at Socket.Readable.push (node:internal/streams/readable:228:10)
at TCP.onStreamRead (node:internal/stream_base_commons:199:23) {
length: 168,
severity: 'FATAL',
code: '28000',
detail: undefined,
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'auth.c',
line: '496',
routine: 'ClientAuthentication'
},
original: error: no pg_hba.conf entry for host "186.194.175.39", user "xuavcbfkstvqrm", database "d3t76co8ov8vqm", SSL off
at Parser.parseErrorMessage (d:\Projetos-VSCODE\Crud-tsnode\node_modules\pg-protocol\src\parser.ts:369:69)
at Parser.handlePacket (d:\Projetos-VSCODE\Crud-tsnode\node_modules\pg-protocol\src\parser.ts:188:21)
at Parser.parse (d:\Projetos-VSCODE\Crud-tsnode\node_modules\pg-protocol\src\parser.ts:103:30)
at Socket.<anonymous> (d:\Projetos-VSCODE\Crud-tsnode\node_modules\pg-protocol\src\index.ts:7:48)
at Socket.emit (node:events:390:28)
at Socket.emit (node:domain:475:12)
at addChunk (node:internal/streams/readable:315:12)
at readableAddChunk (node:internal/streams/readable:289:9)
at Socket.Readable.push (node:internal/streams/readable:228:10)
at TCP.onStreamRead (node:internal/stream_base_commons:199:23) {
length: 168,
severity: 'FATAL',
code: '28000',
detail: undefined,
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'auth.c',
line: '496',
routine: 'ClientAuthentication'
}
}
What is missing in my code to connect correctly?, doing this test and being able to connect to the postgresql database on heroku, I will upload the application and I believe that the CRUD that needs to access the route and add the user will work, but I have to do it this connection to the heroku database, but I'm not getting it
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
