Retrieving direct DATABASE_URL after losing it (without internal host?)

Hello,
I have created a few apps a few years ago, front + back + db. I almost didn’t have to deal with Fly.io since I started this project, and today everything still runs smoothly. But I lost access to the db on my DBMS and I can’t manage to figure out of to get the URL back.

I tried to connect to the api app with fly ssh console and do echo $DATABASE_URL but the host given appears to be an internal one; and I still can’t connect to the db with my DBMS.

How can I get a valid URL from which I can connect directly from my machine to the DB ?

Thanks in advance

It’s easy to open a tunnel into your org’s wireguard bounded network. Once you are there you can use the URL from DATABASE_URL.

You can also use fly proxy with the credentials in the URL you got, but replace the host part with localhost. You can find more details on how to connect to your postgres app here: Legacy Fly Postgres Clusters · Fly Docs

Hi, thanks a lot!

To be clear if anyone stumbles upon this question, here’s what I did to be able to connect to my db :

  1. From your app folder (the app using the DATABASE_URL env var) : fly console ssh
  2. Then, once connected : echo $DATABASE_URL
  3. Copy the url with the credentials and quit the ssh connection.
  4. fly proxy 5432 -a YOUR_DB_APP_NAME
  5. Then you can use your DBMS with the URL, replacing the host from the pasted URL with localhost
1 Like

Glad I could help

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.