is there any way to see data in database like normally we can connect our postgres database to pgAdmin?

I want to see the data in tables of my database

If you want to check the tables in your database you can do this:

flyctl ssh console --app postgres-app-here
psql -h 127.0.0.1 -U user-you-want-here

Then in psql you can use the command \d to list the tables in your database.

For accessing it through pgAdmin, it’s a bit different. The database is accessed by your other apps over private networks, so you’ll need to make a tunnel between your computer and the database. You can use Wireguard to create a tunnel. Then you can connect to the database in pgAdmin with the internal address (e.g. paulgra-ham.internal) and your credentials.

You can read more about how to setup Wireguard with this reference:

It’s gotten even easier! Try flyctl postgres connect for psql, or flyctl proxy to forward a port to your local machine (that you can point pgAdmin to), without setting up your own WireGuard.

More in the Fly Postgres docs

also:

can you please help me in it I’m still not sure how to do it I have tried steps over there but it does nothing for me

usama@Usamas-MacBook-Pro chatapp % flyctl proxy 5432 -a my-db         
usama@Usamas-MacBook-Pro chatapp % psql postgres://postgres:password@localhost:5432
psql (14.1)
Type "help" for help.

postgres=#  

what next?

How to connect fly.io postgres to pg_admin any step by step guide please

Did you let the proxy command keep running? You can’t cancel it, it needs to stay running in a tab.

That psql command looks like it might have worked. You could also connect from something like Postico, which is a little easier than a CLI. If you want to use psql you can actually run:

flyctl pg connect -a <db-name>

Then follow these instructions: psql command line tutorial and cheat sheet | postgres


want to connect it here this is not working for me commands are working fine

You’ve forwarded the database port to port 5432 on your computer (localhost).

At this point it’s just a matter of setting up pgAdmin or whatever other client you want to use. Server Dialog — pgAdmin 4 6.5 documentation

I would need the same! I’ve been trying to set up my database in Postico and the pg_admin steps aren’t clear to me

did you found the solution?

Hi @cschull and @usama !

This is how I’d set my database to be accessible on localhost.

On your terminal write the command:

$ fly proxy 6543:5432 -a app-name
Proxying local port 6543 to remote [app-name.internal]:5432

This command will expose the port 5432 from your app to your localhost:6543 (feel free to change this number)

On your Postico/Client app do this

The host should be localhost and the port should be the one you choose (in my example 6543).

Read more: Fly Postgres · Fly Docs

fly proxy 6543:5432 -a app-name
taking to long to respond any idea?

Hi, this solves the connection problem. I can connect to my database using dbeaver client app but unfortunately, I cannot see the tables. How can this be fixed? I am sure tables exist because my app can query database but just I can’t see them.

image_2023-01-17_125158871

Edit your databse and check show all database

Thanks, but I can see all databases. Can’t see just tables. Maybe this is a bug of Dbeaver.

This is how you will get the table you’re looking for
image

Hi Usama,

Did you happen to find a solution for this? I seem to be having the exact same issues as you.

Thanks,
George.

could somebody put a example with pgadmin, because its gave me a error, telling me: connection refused (0x0000274D/10061)

99% of the time when I have connection refused it’s when I use the wrong host or I forget to set a host.

I’m not familiar with pgadmin but you’d want to check if the host (or the entire connection string if that’s the case) has the proper db-app-name.internal or db-app-name.flycast (if you have a fly cast IP there).

The way that worked for me was to expose the port on my machine and when configuring the server in pgAdmin, define the hostname as localhost