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}

Submit an answer

This textbox defaults to using Markdown to format your answer.

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

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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