psql postgres://USERNAME:PASSWORD@localhost:15432
psql: error: connection to server at "localhost" (::1), port 15432 failed: Connection refused
Is the server running on that host and accepting TCP/IP connections?
connection to server at "localhost" (127.0.0.1), port 15432 failed: FATAL: database "pricing_livebook" does not exist
But: fly postgres connect --app APP --database DB
is working fine.
I think you want fly proxy 15432:5432 -a <db-name> in the first example. postgres connect loads up a shell, proxy forwards the port so you can connect with other tools.
Sorry to ask another obvious question, but are you letting the proxy command keep running while you try to connect? If you cancel that command the proxy stops, so you’ll need to psql from another terminal.
Ok, it wasn’t that. But I had attached a new app to an existing database, which generated a new username. And it appears that, because I had not specified a database in my psql command, that it was looking for one with the same name as my username. Adding the database name let the connection work.
The next problem was that I could connect, but not query the tables for lack of permissions. I had to grant those permissions explicitly to the new user. I can see how that might be the desired behavior, but it might be worth noting somewhere