Abhishek Chadha
Abhishek Chadha

Reputation: 440

How to set a fixed DATABASE_URL for Heroku Postgres

I am using a professional tier Heroku Postgres database. The DATABASE_URL changes whenever maintenance is conducted. This fact makes it essentially impossible for us to connect external apps to this database instance since they break at regular intervals whenever maintenance is conducted.

I require a static, unchanging URL or IP address to my Postgres instance so that external applications can have an uninterrupted connection to the database across maintenance windows.

Upvotes: 0

Views: 1095

Answers (1)

Tin Nguyen
Tin Nguyen

Reputation: 5330

https://devcenter.heroku.com/articles/connecting-to-heroku-postgres-databases-from-outside-of-heroku

The database URL is managed by Heroku and will change under some circumstances such as:

  • User-initiated database credential rotations using heroku pg:credentials:rotate.
  • Catastrophic hardware failures that require Heroku Postgres staff to recover your database on new hardware.
  • Security issues or threats that require Heroku Postgres staff to rotate database credentials.
  • Automated failover events on HA-enabled plans.

Check if this is an option for your setup:

DATABASE_URL=$(heroku config:get DATABASE_URL -a your-app) your_process

You supply the DATABASE_URL to your external app/process. You can also build a small service that redirects a static URL to that dynamic DATABASE_URL.

Upvotes: 1

Related Questions