Job component in app platform to run rails migrations and this error occurs - URI::InvalidURIError: bad URI(is not URI?): ${db.DATABASE_URL}

I have a rails app with a managed development database and I am trying to add a job to migrate my rails app before each deploy.

I set the environment variable DATABASE_URL with a value of ${db.DATABASE_URL}.

But it seems like the connection parameters are not being passed and instead is passing a string directly which causes this error.

URI::InvalidURIError: bad URI(is not URI?): ${db.DATABASE_URL}

How can I pass the database connection parameters correctly in a job?

Show comments

Submit an answer
Answer a question...

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.

Bobby Iliev
Site Moderator
Site Moderator badge
June 27, 2022

Hi there Drew,

Is the name of your database db? The syntax is the following:


If you’ve named your database differently, you need to change the db part accordingly to match your database name.

Let me know how it goes:



Hi @DrewTerry

Try to define your DATABASE_URL as follows:


Then you must create the environment variable in .bashrc file:

$ nano ~/.bashrc

Puts your DATABASE_URL variable at the end of the file:

export DATABASE_URL="postgres://user:pass@localhost/dbname"

Finally, saves file and execute the content of the file:

$ source ~/.bashrc

Hope helps you,

Sergio Turpín

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.