I apologize for the trouble, but I have searched similar issues but to no avail.
I have a Postgres Server (PgServer) running inside Docker (attached is an image). It works fine with no issues. I ran this PgServer using the following command
docker run --name PgServer --network=brapi_network -e POSTGRES_PASSWORD=****-d postgres
The application properties of this docker container, or jdbc database (sorry still a beginner at these technical terms) is as follows
server.port = 8080
server.servlet.context-path=/brapi/v2
spring.datasource.url=jdbc:postgresql://PgServer:5432/brapi_local
spring.datasource.username=postgres
spring.datasource.password=******
I have a very simple node client that tries to connect to this database and does a simple select * from table
query. Code is below:
const {Client} = require('pg')
const client = new Client({
host: "PgServer",
user: "postgres",
port: 8080,
password: "*****",
database: "brapi_local"
})
Whenever I try to run this node client app, I always get the following error
(node:4448) UnhandledPromiseRejectionWarning: Error: getaddrinfo ENOTFOUND PgServer
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:67:26)
What could I be doing wrong?