Share via

Error conection postgres

Andrei Haba 0 Reputation points
2024-01-06T08:57:16.6266667+00:00

I have a VM on Azure from which I'm trying to connect to a PostgreSQL database on Azure. The connection is not working, but if I use VS Code on Windows, the connection works. I have checked ufw, the firewall, and PostgreSQL. I have also installed PostgreSQL. Please tell me where to check. This

require('dotenv').config();
const { Client } = require("pg");

const {HOST, USER, PORT, PASSWORD, DATABASE} = process.env;
const client = new Client({
  host:HOST, user:USER, port:PORT, password:PASSWORD, database:DATABASE
});

client.connect();

module.exports = {client};
//console.log(client);
//console.log(client.query, '999999999999999999999999')
//console.log({  host:HOST, user:USER, port:PORT, password:PASSWORD, database:DATABASE})

setInterval(()=>{
  client.query('select * from preturi order by id limit 1', (err, data)=>{
    if(err){
      console.log(err, 'eroarea -----------------------------------')
    }else{
      console.log(data.rows, 'r ca au veni datele 5555555555555
Azure Database for PostgreSQL

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.