Cannot connect to PostgreSQL my-chat-app-db-vittorio - "FATAL: password authentication failed"

The persistent error I’m receiving is:
FATAL: password authentication failed for user "postgres"

This error occurs both when my FastAPI backend (running locally and connecting via an SSH tunnel) tries to connect, and critically, even when I use the flyctl postgres connect -a my-chat-app-db-vittorio command.

The fact that flyctl postgres connect (which should use an internal Fly.io connection) also fails with the exact same FATAL: password authentication failed for user "postgres" error suggests a deeper problem with the postgres user’s credentials or state directly on the database instance itself.

Actions I’ve already attempted:

  • Confirmed the database is “Deployed” and appears active on the dashboard.
  • Verified that the flyctl proxy tunnel to my database is active and functioning (the error is no longer “Connection refused” or “Unknown host”).
  • Attempted to reset the postgres user’s password multiple times:
    • Via ALTER USER directly from psql (when flyctl connect was working previously).
    • Via flyctl secrets set DB_PASSWORD='[TEMPORARY_PASSWORD_USED_FOR_TESTING]' --app my-chat-app-db-vittorio.
  • Ensured the password [TEMPORARY_PASSWORD_USED_FOR_TESTING] is perfectly aligned across all my local configurations (.env file, DBeaver).
  • Confirmed sslmode=disable in my local connection strings (as required for the tunnel connection).
  • My current public IP is [MY_PUBLIC_IP_ADDRESS].
  • DBeaver, configured for a local tunnel connection, user postgres, and SSL disabled, also gives the same “password authentication failed” error when attempting a connection test.

Given that even Fly.io’s internal connection tool (flyctl connect) is failing with an authentication error, I suspect there’s an underlying issue with the postgres user’s credentials or status on the database instance itself that I cannot resolve from my side.

Could you please help me diagnose and resolve this? I urgently need to restore access to my database.

Thank you for your your urgent assistance!

1 Like

Hi… Sorry to hear you’re having trouble! This is a public forum, though, so you don’t want to post your password, :dragon:.

Try editing it out, via the small pencil icon in the toolbar at the bottom of the post…

(Failing that, I’d delete it entirely.)

1 Like

Hello everyone,

I’m experiencing a critical authentication issue with my PostgreSQL database my-chat-app-db-vittorio on Fly.io, preventing me from accessing it from anywhere.

The persistent error I’m receiving is:
FATAL: password authentication failed for user "postgres"

This error occurs both when my FastAPI backend (running locally and connecting via an SSH tunnel) tries to connect, and critically, even when I use the flyctl postgres connect -a my-chat-app-db-vittorio command.

The fact that flyctl postgres connect (which should use an internal Fly.io connection) also fails with the exact same FATAL: password authentication failed for user "postgres" error suggests a deeper problem with the postgres user’s credentials or state directly on the database instance itself.

Actions I’ve already attempted:

  • Confirmed the database is “Deployed” and appears active on the dashboard.
  • Verified that the flyctl proxy tunnel to my database is active and functioning (the error is no longer “Connection refused” or “Unknown host”).
  • Attempted to reset the postgres user’s password multiple times:
    • Via ALTER USER directly from psql (when flyctl connect was working previously).
    • Via flyctl secrets set DB_PASSWORD='[TEMPORARY_PASSWORD_USED_FOR_TESTING]' --app my-chat-app-db-vittorio.
  • Ensured the password [TEMPORARY_PASSWORD_USED_FOR_TESTING] is perfectly aligned across all my local configurations (.env file, DBeaver).
  • Confirmed sslmode=disable in my local connection strings (as required for the tunnel connection).
  • My current public IP is [MY_PUBLIC_IP_ADDRESS].
  • DBeaver, configured for a local tunnel connection, user postgres, and SSL disabled, also gives the same “password authentication failed” error when attempting a connection test.

Given that even Fly.io’s internal connection tool (flyctl connect) is failing with an authentication error, I suspect there’s an underlying issue with the postgres user’s credentials or status on the database instance itself that I cannot resolve from my side.

Could you please help me diagnose and resolve this? I urgently need to restore access to my database.

Thank you for your your urgent assistance!

In general, if you can SSH into the Postgres instance, then you should be able to bypass password authentication altogether:

$ fly ssh console --app my-chat-app-db-vittorio
# su postgres
$ psql -p 5433  # not just for tcp, also determines the unix-domain socket (surprisingly)

(Note that this is 5433, not the usual 5432.)

This uses the Machine-local Linux credentials, basically.

If that works, then I would try making a completely new user that has access to the tables that you need from FastAPI, etc.

(Or, if worse comes to worst, you can pg_dump from in there and start over with a fresh Postgres app…)

1 Like

Thank you so much, mayailurus!

I followed your instructions on how to SSH into the database machine and use psql -p 5433 to create a new user. It worked perfectly!

Finally, my FastAPI backend has started up and is connecting to the database on Fly.io. The chat is back online!

I really appreciate your patience and exceptional help. You were absolutely key to solving this!

Thanks again!

1 Like

I am pleased your problem is solved, @sbirringa.

A helpful note on this forum. Many of us are fellow customers, and some of us lurk here to share our knowledge and/or because we like helping. Some folks here are Fly employees, and they often solve technical problems here pro bono, especially if the error was caused on the Fly side. However, if I understand their prior pronouncements correctly, their official support channel is a paid one, and is via email.

So this forum appears to be based on a mix of best endeavours and volunteering. With that in mind, questions posted here are probably best not marked as urgent. Volunteers will help you at their leisure, and if you need technical backup, subscribing to Fly’s technical support service may be worth considering.

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