(I'm korean. My English can be terrible.)
I want my node app to connect AWS RDS.
but the error occured.
how can I sovle this?
Error Message
enter image description here
My Code
config/db.js
require("dotenv").config();
const { Pool } = require("pg");
const pool = new Pool({
host: process.env.PG_DB_HOST,
port: process.env.PG_DB_PORT,
user: process.env.PG_DB_USER,
password: process.env.PG_DB_PASSWORD,
database: process.env.PG_DB_DATABASE,
});
const pgQuery = async (query) => {
const client = await pool.connect();
try {
return await client.query(query);
} catch (err) {
throw new Error(err);
} finally {
client.release();
}
};
(async function () {
await pgQuery("SELECT * FROM table_name");
})();
console.log("POSTGRESQL is connected");
module.exports = pgQuery;
Local connection is working well.
I'm using AWS RDS Postgresql.