I’m having trouble connecting to our Postgres DB using the external connection string provided by Render. Below is my basic setup to connect taken from https://node-postgres.com/features/connecting, I keep running into this Error: read ECONNRESET at TCP.onStreamRead
.
Connecting to the DB on my local machine works fine. I’m a beginner and most likely overlooking something. Any help will be appreciated.
const dotenv = require('dotenv');
const { Client } = require('pg');
dotenv.config();
const connectionString = process.env.RENDER_CONNECTION_STRING;
const client = new Client({
connectionString
});
const queryDB = async () => {
await client.connect();
client.query('SELECT NOW()', (err, res) => {
console.log(err, res);
client.end();
});
};
(async () => {
try {
await queryDB();
} catch (error) {
console.error(error);
}
})();