(Mix) Could not start application web: {:not_running, :database}

Hi! May someone helps me, please? I get the next error after adding Database into defp deps in the mix.exs and trying to run mix phx.server :

[error] GenServer #PID<0.502.0> terminating
** (RuntimeError) connect raised KeyError exception: key :database not found. The exception details are hidden, as they may contain sensitive data such as database credentials. You may set :show_sensitive_data_on_connection_error to true when starting your connection if you wish to see all of the details
    (elixir) lib/keyword.ex:393: Keyword.fetch!/2
    (postgrex) lib/postgrex/protocol.ex:92: Postgrex.Protocol.connect/1
    (db_connection) lib/db_connection/connection.ex:69: DBConnection.Connection.connect/2
    (connection) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: nil
State: Postgrex.Protocol
[info] Application database exited: shutdown
** (Mix) Could not start application web: {:not_running, :database}

This is my code:

  defp deps do
    [
      {:phoenix, "~> 1.4.9"},
      {:phoenix_pubsub, "~> 1.1"},
      {:phoenix_html, "~> 2.11"},
      {:phoenix_live_reload, "~> 1.2", only: :dev},
      {:gettext, "~> 0.11"},
      {:jason, "~> 1.0"},
      {:plug_cowboy, "~> 2.0"},
      {:database, in_umbrella: true}, # Here is my database dep.
      {:ueberauth, "~> 0.3"},
      {:ueberauth_google, "~> 0.7"}
    ]
  end
end

Looks like you are missing the Ecto repo config section in config\dev.exs, or it is incomplete. You should have something like:

config :myapp, MyApp.Repo,
  username: "postgres",
  password: "secret",
  database: "myapp_dev",
  hostname: "localhost",
  pool_size: 10

Where myapp, MyApp.Repo etc match whatever your application is called.

1 Like

It works! thanks a lot!