I have access to a remote postgres DB from pgAdmin4 and I also could access from nodejs using a Mac. Right now I'm using the same code to access the DB in Windows. The code for my connection is the following:
const { Client } = require('pg'); //Importing the Postgres package
const hosts= require('../hosts'); //Using the file containig all hosts
const connectionData = { //Begin creating the connection settings object
host: hosts.DBHost, //DB host
port: hosts.DBPort, //DB hosts port
database: hosts.DB, //DB
user: hosts.DBUser, //DB user
password: hosts.DBPassword, //DB user password
}
My test is the following:
var client = new Client(connectionData); //New client instance using the above connection settings
client.connect(); //Open the connection to the database()
sql = "select * from myTable";
client.query(sql)
.then(response => {
console.log ({"data": response}); //This isn't shown
})
.catch(err => {
console.log({"error": err}); //This isn't shown neither
})
No error, no exception, the DB server doesn't respond!
Why isn't the server responding?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…