Error with Ecto setup , following a tutorial

Hello,

I am. very new to Elixir lang I have only been doing it for about 2 weeks. I recently started following this tutorial todo list, and I am running into errors, everything was fine until timestamp 3:15 where “mix ecto.setup” is introduced. When I run this I immediately get
this error below?

`00:40:53.173 [error] GenServer #PID<0.289.0> terminating
** (Postgrex.Error) FATAL 28000 (invalid_authorization_specification) role “postgres” does not exist
(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 3.17) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Last message: nil
State: Postgrex.Protocol

00:40:53.208 [error] GenServer #PID<0.296.0> terminating
** (Postgrex.Error) FATAL 28000 (invalid_authorization_specification) role “postgres” does not exist
(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 3.17) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Last message: nil
State: Postgrex.Protocol
** (Mix) The database for LiveViewTodos.Repo couldn’t be created: killed`

I am not sure how to fix it, I tried reinstalling and redoing, but nothing will get rid of this error. I created my own postgres Database on my local machine. How can connect it with the new project I am unable to continue the tutorial. I want to know what am I doing wrong? how can I fix this and continue my tutorial?

Dennis’ blog post for this video doesn’t seem to go into any detail about setting up your database so it’s running the default config set up by phx.new.

The likely issue is your Repo config in config/dev.exs doesn’t match the username you used to set up your postgres database.

The defaults are:

config :live_view_todos, LiveViewTodos.Repo,
  username: "postgres",
  password: "postgres",
  hostname: "localhost",
  database: "live_view_todos_dev",
  show_sensitive_data_on_connection_error: true,
  pool_size: 10

So change the username and password to whatever you set up.

Hello,

thank you for getting back to me. SInce I have created a database with postgres on my local, would I be able to put in my username and password and database.

That’s right, you must replace "postgres" in the username and password config to you local database’s settings.

Also change the hostname if it’s different.

Thank you so much,
I was able to fix it, moving forward how can I avoid this from happening?

There’s no silver bullet. A big part of learning any new system is understanding how it configures itself and starts up and this is one of the first settings one should check when starting fresh.

1 Like