I'm trying to connect to Pg but for some reason it throws an exception:
//........
app.post("/some_url", (req, res) => {
const client = new pg.Client({user: "user1", password: "password$", database: "some_db", host: "127.0.0.1"});
client.connect((err) => {
if (err) {
throw err;
}
//.......
Here's an error:
events.js:163
throw er; // Unhandled 'error' event
^
Error: Connection terminated
at Connection.<anonymous> (/home/user1/app_123/node_modules/pg/lib/client.js:199:29)
at Object.onceWrapper (events.js:293:19)
at emitNone (events.js:91:20)
at Connection.emit (events.js:188:7)
at Socket.<anonymous> (/home/user1/app_123/node_modules/pg/lib/connection.js:141:10)
at emitNone (events.js:91:20)
at Socket.emit (events.js:188:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)
How to fix it?
via Dorion
No comments:
Post a Comment