I have exhausted my attempts to connect to my PostgreSQL Hyperscaler instance in BTP and thought I'd reach out to the community for help since I wasn't able to find an answer yet. I have a working node express api app that leverages a local postgreSQL database and returns data. But when I deploy to BTP I cannot connect to my PostgreSQL Hyperscaler instance - I get a 502 Bad Gateway response.
My question is what I do to connect to the database once I deploy the app to BTP? Can someone indicate what I'm doing wrong in my connection code?
Here is the Bind Service (some information removed):
{
"username": "9a5121579182",
"password": "XXXXXXXXXX",
"hostname": "postgres-fdb76d9f-e770-4d87-8cff-c105aa990222.cqryblsdrbcs.us-east-1.rds.amazonaws.com",
"dbname": "XXXXXXXXXX",
"port": "3959",
"uri": "postgres://9a5121579182:XXXXXXXXXX@postgres-fdb76d9f-e770-4d87-8cff-c105aa990222.cqryblsdrbcs.us-east-1.rds.amazonaws.com:3959/XXXXXXXXXX",
"sslcert": "-----BEGIN CERTIFICATE-----REMOVED FOR EXAMPLE-----END CERTIFICATE-----",
"sslrootcert": "-----BEGIN CERTIFICATE-----REMOVED FOR EXAMPLE-----END CERTIFICATE-----"
}
Here is my connection in my queries.js file .env populated with the Bind Service information from above.
const Pool = require('pg').Pool
const pool = new Pool({
user: `${process.env.DB_USER}`,
host: `${process.env.DB_HOST}`,
database: `${process.env.DB_DATABASE}`,
password: `${process.env.DB_PASSWORD}`,
port: `${process.env.DB_PORT}`
})
Here is my VCAP_SERVICES results:
VCAP_SERVICES: {
"postgresql-db": [
{
"binding_guid": "4d953482-131d-4729-aa3a-812ef796da51",
"binding_name": null,
"credentials": {
"dbname": "XXXXXXXXXX",
"hostname": "postgres-fdb76d9f-e770-4d87-8cff-c105aa990222.cqryblsdrbcs.us-east-1.rds.amazonaws.com",
"password": "XXXXXXXXXX",
"port": "3959",
"sslcert": "-----BEGIN CERTIFICATE-----REMOVED FOR EXAMPLE-----END CERTIFICATE-----",
"sslrootcert": "-----BEGIN CERTIFICATE-----REMOVED FOR EXAMPLE-----END CERTIFICATE-----"
"uri": "postgres://9a5121579182:XXXXXXXXXX@postgres-fdb76d9f-e770-4d87-8cff-c105aa990222.cqryblsdrbcs.us-east-1.rds.amazonaws.com:3959/XXXXXXXXXX",
"username": "9a5121579182"
},
"instance_guid": "fdb76d9f-e770-4d87-8cff-c105aa990222",
"instance_name": "XXXXXXXXXX",
"label": "postgresql-db",
"name": "XXXXXXXXXX",
"plan": "trial",
"provider": null,
"syslog_drain_url": null,
"tags": [
"relational",
"database"
],
"volume_mounts": []
}
]
}
Request clarification before answering.
The "required" property is a boolean and be set to "true".
ssl: {
require: true,
rejectUnauthorized : false
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 10 | |
| 5 | |
| 5 | |
| 5 | |
| 5 | |
| 2 | |
| 2 | |
| 2 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.