Skip to content

Problems connecting to Postgres with SSL #825

@lucamarchiori

Description

@lucamarchiori

I tried to connect Edgehog to a Postgres instance that requires SSL with the following Edgehog configuration:

DATABASE_SSL_VERIFY = "false"
DATABASE_ENABLE_SSL = "true"

I get this error:

level=error ts=2025-04-16T09:22:06.010+00:00 msg="Postgrex.Protocol (#PID<0.151.0>) failed to connect: ** (Postgrex.Error) FATAL 28000 (invalid_authorization_specification) pg_hba.conf rejects connection for host \"10.244.0.39\", user \"edgehog-dev.walter\", database \"edgehog\", no encryption" module=DBConnection.Connection function=handle_event/4
level=error ts=2025-04-16T09:22:06.010+00:00 msg="Postgrex.Protocol (#PID<0.150.0>) failed to connect: ** (Postgrex.Error) FATAL 28000 (invalid_authorization_specification) pg_hba.conf rejects connection for host \"10.244.0.39\", user \"edgehog-dev.walter\", database \"edgehog\", no encryption" module=DBConnection.Connection function=handle_event/4
level=error ts=2025-04-16T09:22:07.354+00:00 msg="Postgrex.Protocol (#PID<0.151.0>) failed to connect: ** (Postgrex.Error) FATAL 28000 (invalid_authorization_specification) pg_hba.conf rejects connection for host \"10.244.0.39\", user \"edgehog-dev.walter\", database \"edgehog\", no encryption" module=DBConnection.Connection function=handle_event/4
level=error ts=2025-04-16T09:22:08.743+00:00 msg="Postgrex.Protocol (#PID<0.150.0>) failed to connect: ** (Postgrex.Error) FATAL 28000 (invalid_authorization_specification) pg_hba.conf rejects connection for host \"10.244.0.39\", user \"edgehog-dev.walter\", database \"edgehog\", no encryption" module=DBConnection.Connection function=handle_event/4
level=error ts=2025-04-16T09:22:08.933+00:00 msg="Could not create schema migrations table. This error usually happens due to the following:\n\n  * The database does not exist\n  * The \"schema_migrations\" table, which Ecto uses for managing\n    migrations, was defined by another library\n  * There is a deadlock while migrating (such as using concurrent\n    indexes with a migration_lock)\n\nTo fix the first issue, run \"mix ecto.create\" for the desired MIX_ENV.\n\nTo address the second, you can run \"mix ecto.drop\" followed by\n\"mix ecto.create\", both for the desired MIX_ENV. Alternatively you may\nconfigure Ecto to use another table and/or repository for managing\nmigrations:\n\n    config :edgehog, Edgehog.Repo,\n      migration_source: \"some_other_table_for_schema_migrations\",\n      migration_repo: AnotherRepoForSchemaMigrations\n\nThe full error report is shown below.\n" module=Ecto.Migrator function=verbose_schema_migration/3
** (DBConnection.ConnectionError) connection not available and request was dropped from queue after 2988ms. This means requests are coming in and your connection pool cannot serve them fast enough. You can address this by:

  1. Ensuring your database is available and that you can connect to it
  2. Tracking down slow queries and making sure they are running fast enough
  3. Increasing the pool_size (although this increases resource consumption)
  4. Allowing requests to wait longer by increasing :queue_target and :queue_interval

See DBConnection.start_link/2 for more information

    (ecto_sql 3.12.0) lib/ecto/adapters/sql.ex:1078: Ecto.Adapters.SQL.raise_sql_call_error/1
    (elixir 1.17.2) lib/enum.ex:1703: Enum."-map/2-lists^map/1-1-"/2
    (ecto_sql 3.12.0) lib/ecto/adapters/sql.ex:1185: Ecto.Adapters.SQL.execute_ddl/4
    (ecto_sql 3.12.0) lib/ecto/migrator.ex:779: Ecto.Migrator.verbose_schema_migration/3
    (ecto_sql 3.12.0) lib/ecto/migrator.ex:563: Ecto.Migrator.lock_for_migrations/4
    (ecto_sql 3.12.0) lib/ecto/migrator.ex:432: Ecto.Migrator.run/4
    (ecto_sql 3.12.0) lib/ecto/migrator.ex:170: Ecto.Migrator.with_repo/3
    nofile:1: (file)
Stream closed EOF for edgehog-dev/edgehog-backend-845f6bcd78-w2hm7 (edgehog-backend)

With the same Postgres instance with SSL disabled and DATABASE_ENABLE_SSL = false on Edgehog everything works as expected.

Related issue: #419
Related PR: #777

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions