** (Postgrex.Error) FATAL 08P01 (protocol_violation) no such database: postgres

I have had success with this even recently but Im missing something now.

I am simply attempting to connect with a remote database on a new phoenix installation.

The service is not called “postgres” buy my_app is still looking for a db named Postgres apparently.

replacing the primary database connection, not adding a second.

same result using both a clean install, or a template from fullstackphoenix.

I followed this guide
among other guides for database migrations such as:

I configure the adapter in config/devs.ex file with the appropriate credentials

  username: "NOT_postgres",
  password: "NOT_postgres",
  hostname: "remote_connection-pool_digital-ocean.com",
  database: "NOT_postgres",
  port: "25061",
  ssl: true,
  ssl_opts: [verify: :verify_peer, cacertfile: 'ca-certificate.crt'],
  stacktrace: true,
  show_sensitive_data_on_connection_error: true,
  pool_size: 10

Then any mix ecto gets this error

11:19:58.852 [error] GenServer #PID<0.398.0> terminating
** (Postgrex.Error) FATAL 08P01 (protocol_violation) no such database: postgres
    (db_connection 2.4.2) lib/db_connection/connection.ex:100: DBConnection.Connection.connect/2
    (connection 1.1.0) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib 4.1.1) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
Last message: nil
State: Postgrex.Protocol

I am wondering where else I need to declare db credentials. Or if there is something else simple I am forgetting.

I have tried adding credential in config/test.exs but it didn’t make a difference. and considered add to runtime.exs, but runtime.exs loads database_url from system environment exports. which are set.

Any assistance would be of value. Thanks…

Hi @humankindof if you are editing the dev.exs file, but are doing a deployment, that wont’ work. dev.exs configures your local development environment. When you do a deployment it’s running in the prod environment, and so you need to be setting values in runtime.exs.

You’ll see your runtime.exs file has an area enclosed in this block:

if config_env() == :prod do
# put your prod postgres details here
1 Like

That was it man. Thank You.

1 Like