Elixir, Ecto / Phoenix + Managed Postgres Db

March 12, 2019 562 views
Docker

I’m trying to setup an Elixir / Phoenix / Ecto project on my droplet and connect to a DO managed postgresql. No matter what I do I can’t connect to my DB properly:

** (Postgrex.Error) FATAL 3D000 (invalidcatalogname) database “postgres” does not exist
(dbconnection) lib/dbconnection/connection.ex:84: DBConnection.Connection.connect/2
(connection) lib/connection.ex:622: Connection.enterconnect/5
(stdlib) proc
lib.erl:249: :proclib.initpdoapply/3

My connection string is right, connectivity seems fine ( I setup my droplet to be able to access the db cluster) but Elixir/Ecto complains with the above error.

1 Answer
bhogan MOD March 13, 2019
Accepted Answer

HI! Sorry to hear you ran into a snag. I just set up a brand new Elixir/Phoenix app myself and ran into the exact same issue you had.

I did a little digging and it seems that either Ecto or Postgres expects the postgres database to exist.

I logged into the db directly with my doadmin user and looked around, and surely enough there’s no postgres database. So I created one:

CREATE DATABASE postgres WITH OWNER doadmin

Then I disconnected from the console, re-ran mix ecto.create and was greeted with:

The database for Hello.Repo has been created

I hope that helps move you forward!

Have another answer? Share your knowledge.