0

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.

  • Is there a recommended way of setting this up? If not I will have to perform a migration to some other service provider because performing an update to all my infrastructure or creating polling mechanisms to get around this problem is not feasible.
  • A less important question but why does Heroku Postsgres keep changing the URL? Is it for security? There is nothing in their documentation that explains why this happens.

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

This is not an option for my environment as Heroku CLI is not available or logged in on the external machines. Furthermore, there are no notifications that the URL has changed making a regular pessimistic restarts required.
@sebastian there was no good solution on Heroku. We ran a cron job to periodically sync DATABASE_URL. Ended up migrating to NeonDB evenutally.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.