How to connect to posgres database using fly cli

How I can connect to the Postgres database, that was created as part of fly deploy command result?

So far I have tried the below, but nothing worked for me,

flyctl postgres connect

fly proxy 6543:5432 -a  <app_name>

Could someone help me, Thanks in advance :pray:

Edit

I don’t have any error logs, but they hung upon issuing the command, below is the screenshot for the same.

Hi @lakki, if you share the output you saw when you tried these commands, it will be easier to help you get to the bottom of this.

1 Like

Thank @catflydotio for pointing it out, I have updated the question with the issue screenshot. May be I am using wrong command completely.

With this info I have a couple of suggestions.

  1. Try fly postgres connect -a <app-name>. If the fly.toml belonging to the app you want to connect to is not present in your working directory, you need to specify the app to apply the command to.

  2. The proxy command output looks as you’d expect it to. It doesn’t return because, well, it needs to keep proxying that port until you’re done using it. You’d have to open another terminal and do something like

psql postgresql://127.0.0.1:6543

to get a Postgres shell this way.