Question

Node app not picking up the DATABASE_URL env

I am trying to Node app that use Postgraphile which connect to a development database($7), but I am getting following error from Node app which is caused due to DATABASE_URL.

Error: Errors occurred during settings validation:
Setting 'connectionString': Expected a string, or for DATABASE_URL envvar to be set

But in env vars of node app component there is indeed the DATABASE_URL which is set to ${db.DATABASE_URL} which was automatically added when attaching the development database to the app.

I am confused what is going on here?


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.

KFSys
Site Moderator
Site Moderator badge
January 31, 2023
Accepted Answer

Hi @kaushalyap,

I’ll recommend giving the following a read:

https://docs.digitalocean.com/products/app-platform/how-to/use-environment-variables/

Have you configured the Database URL in the APP-Level Enviroment variables?

Once you enter the bindable variable, click Save. The app redeploys.

You can check that the environment variable works by opening the app’s Console tab and running:

echo $<name-of-environment-variable>
alexdo
Site Moderator
Site Moderator badge
January 31, 2023

Hello @kaushalyap

You can setup environment variables to set the DATABASE_URL

When creating an app, specify environment variables on the Environment screen. Click the Encrypt checkbox to obscure the variable’s values from all build, deployment, and application logs.

https://docs.digitalocean.com/products/app-platform/how-to/connect-pg-pools/#configure-bindable-environment-variables

https://docs.digitalocean.com/products/app-platform/how-to/use-environment-variables/

Hope that this helps!

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.