Question

How to use database_url in App Platform

I am trying to connect the Database on the App Platform and I don’t see anything happened. Connection is not successful.

Env Vars Not Recognized

Description: I have an App Spec:

databases:

  • engine: PG name: db num_nodes: 1 size: db-s-dev-database version: “12” name: portal region: nyc services:
  • dockerfile_path: Dockerfile envs:
  • key: DATABASE_URL scope: RUN_AND_BUILD_TIME value: ${db.JDBC_DATABASE_URL}
  • key: DATABASE_USERNAME scope: RUN_AND_BUILD_TIME value: ${db.USERNAME}
  • key: DATABASE_PASSWORD scope: RUN_AND_BUILD_TIME value: ${db.PASSWORD}
Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hello,

Got to know the below points.

Currently, DATABASE_URL (or any other database bind variables) is not available during build. We plan on supporting build time access to databases soon though we don’t have any ETA. I apologize for the inconvenience caused!

Please change the scope of the Database variables to

databases:
- engine: PG
name: db
num_nodes: 1
size: db-s-dev-database
version: "12"
name: portal
region: nyc
services:
- dockerfile_path: Dockerfile
envs:
- key: DATABASE_URL
scope: RUN_TIME
value: ${db.JDBC_DATABASE_URL}
- key: DATABASE_USERNAME
scope: RUN_TIME
value: ${db.USERNAME}
- key: DATABASE_PASSWORD
scope: RUN_TIME
value: ${db.PASSWORD}

This should work! Hope this helps!

Cheers, Sri Charan