DBConnection.ConnectionError when running a Phoenix migration against an RDS Postgres instance

Hello, i am trying to deploy a phoenix app using an rds postgres instance. I am getting a The database does not exist error

I know the user and password is valid because i can use a psql console to interact with my DB, i think the error might be that this is not running “mix ecto create” maybe?

Is there a way to debug this?

[error] Postgrex.Protocol (#PID<0.167.0>) failed to connect: ** (Postgrex.Error) FATAL 28000 (invalid_authorization_specification) no pg_hba.conf entry for host "200.25.32.84", user "db_user", database "db_dev", no encryption
2025-05-27T16:09:23Z   * The database does not exist
2025-05-27T16:09:23Z   * The "schema_migrations" table, which Ecto uses for managing
2025-05-27T16:09:23Z     migrations, was defined by another library
2025-05-27T16:09:23Z   * There is a deadlock while migrating (such as using concurrent
2025-05-27T16:09:23Z     indexes with a migration_lock)
2025-05-27T16:09:23Z To fix the first issue, run "mix ecto.create" for the desired MIX_ENV.
2025-05-27T16:09:23Z To address the second, you can run "mix ecto.drop" followed by
2025-05-27T16:09:23Z "mix ecto.create", both for the desired MIX_ENV. Alternatively you may
2025-05-27T16:09:23Z configure Ecto to use another table and/or repository for managing
2025-05-27T16:09:23Z migrations:
2025-05-27T16:09:23Z     config :app, App.Repo,
2025-05-27T16:09:23Z       migration_source: "some_other_table_for_schema_migrations",
2025-05-27T16:09:23Z       migration_repo: AnotherRepoForSchemaMigrations
2025-05-27T16:09:23Z The full error report is shown below.
2025-05-27T16:09:23Z ** (DBConnection.ConnectionError) connection not available and request was dropped from queue after 2984ms. This means requests are coming in and your connection pool cannot serve them fast enough. You can address this by:
2025-05-27T16:09:23Z   1. Ensuring your database is available and that you can connect to it
2025-05-27T16:09:23Z   2. Tracking down slow queries and making sure they are running fast enough
2025-05-27T16:09:23Z   3. Increasing the pool_size (although this increases resource consumption)
2025-05-27T16:09:23Z   4. Allowing requests to wait longer by increasing :queue_target and :queue_interval
2025-05-27T16:09:23Z See DBConnection.start_link/2 for more information
2025-05-27T16:09:23Z     (ecto_sql 3.12.1) lib/ecto/adapters/sql.ex:1096: Ecto.Adapters.SQL.raise_sql_call_error/1
2025-05-27T16:09:23Z     (elixir 1.16.0) lib/enum.ex:1700: Enum."-map/2-lists^map/1-1-"/2
2025-05-27T16:09:23Z     (ecto_sql 3.12.1) lib/ecto/adapters/sql.ex:1203: Ecto.Adapters.SQL.execute_ddl/4
2025-05-27T16:09:23Z     (ecto_sql 3.12.1) lib/ecto/migrator.ex:779: Ecto.Migrator.verbose_schema_migration/3
2025-05-27T16:09:23Z     (ecto_sql 3.12.1) lib/ecto/migrator.ex:563: Ecto.Migrator.lock_for_migrations/4
2025-05-27T16:09:23Z     (ecto_sql 3.12.1) lib/ecto/migrator.ex:432: Ecto.Migrator.run/4
2025-05-27T16:09:23Z     (ecto_sql 3.12.1) lib/ecto/migrator.ex:170: Ecto.Migrator.with_repo/3
2025-05-27T16:09:23Z     nofile:1: (file)

Your Phoenix app should have a way to configure the database username, database name, database host, and database password. In general these are supplied in the console when connecting via psql, and so they are held separately.

Have you set these up? These are sometimes stored in a non-committed config file, and sometimes variables that are fed using env vars in TOML and env vars in secrets.

Hello, thanks for answering
yes, i have a DATABASE_URL like
ecto://user:password@host:port/database_name
is that what you mean?

Yes, that’s the sort of thing. However, I have never used Phoenix, so bear that in mind.

Sometimes migration systems use a separate connection string to the main app, so you may need to hunt about for a second one. If you can send a link to the specific part of the documentation you’re studying, that also can be helpful.

I’m also seeing this:

[error] Postgrex.Protocol (#PID<0.167.0>) failed to connect: ** (Postgrex.Error) FATAL 28000 (invalid_authorization_specification) no pg_hba.conf entry for host “200.25.32.84”, user “db_user”, database “db_dev”, no encryption

I searched for “no pg_hba.conf entry for host RDS” in my fave search engine, and found this gem:

So I think that’s the first thing you need to attend to.

:eyes:
let me try this