I am beginning my Elixir/Phoenix journey and having some trouble with my postgres connection.
When I start up my server I get:
$ mix phoenix.server
[error] Postgrex.Protocol (#PID<0.214.0>) failed to connect: ** (Postgrex.Error) tcp connect: connection refused - :econnrefused
[error] Postgrex.Protocol (#PID<0.217.0>) failed to connect: ** (Postgrex.Error) tcp connect: connection refused - :econnrefused
[error] Postgrex.Protocol (#PID<0.218.0>) failed to connect: ** (Postgrex.Error) tcp connect: connection refused - :econnrefused
[error] Postgrex.Protocol (#PID<0.211.0>) failed to connect: ** (Postgrex.Error) tcp connect: connection refused - :econnrefused
[error] Postgrex.Protocol (#PID<0.215.0>) failed to connect: ** (Postgrex.Error) tcp connect: connection refused - :econnrefused
[error] Postgrex.Protocol (#PID<0.219.0>) failed to connect: ** (Postgrex.Error) tcp connect: connection refused - :econnrefused
[error] Postgrex.Protocol (#PID<0.216.0>) failed to connect: ** (Postgrex.Error) tcp connect: connection refused - :econnrefused
[error] Postgrex.Protocol (#PID<0.213.0>) failed to connect: ** (Postgrex.Error) tcp connect: connection refused - :econnrefused
[error] Postgrex.Protocol (#PID<0.212.0>) failed to connect: ** (Postgrex.Error) tcp connect: connection refused - :econnrefused
[error] Postgrex.Protocol (#PID<0.210.0>) failed to connect: ** (Postgrex.Error) tcp connect: connection refused - :econnrefused
[info] Running Rumbl.Endpoint with Cowboy using http://localhost:4000
[error] Postgrex.Protocol (#PID<0.215.0>) failed to connect: ** (Postgrex.Error) tcp connect: connection refused - :econnrefused
Being new to Elixir, Phoenix, and Ecto I am unclear how to debug this problem. Any suggestions as to what my problem is or how I might go about debugging it would be much appreciated.
My app's set up
I have a basic app
mix phoenix.new rumbl
cd rumbl
mix deps.get
mix deps.compile
My config/dev.exs has the following db setup
# Configure your database
config :rumbl, Rumbl.Repo,
adapter: Ecto.Adapters.Postgres,
username: "elixir",
database: "rumbl_dev",
hostname: "localhost",
pool_size: 10
When I run mix ecto.create
there are no errors and I can see the rumbl_dev
when I run \l
in psql. It is owned by the elixir user too.
Running mix ecto.migrate
throws the same connections errors
My pg_hba.conf file has the following
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
Here is what I see when I log in with psql
$ psql --dbname=rumbl_dev --username=elixir --host=127.0.0.1 --password
Password for user elixir:
psql (9.4.5)
Type "help" for help.
rumbl_dev=>
config :rumbl, Rumbl.Repo, adapter: Ecto.Adapters.Postgres, username: "elixir", database: "rumbl_dev", hostname: "localhost", password: "***password***" pool_size: 10
– Mauriciopsql --dbname=rumbl_dev --username=elixir --host=127.0.0.1 --password
– Mauriciohostname: "localhost"
⇒hostname: "127.0.0.1"
might help. – Razzia{:phoenix_ecto, "~> 3.0"}, {:postgrex, ">= 0.0.0"}
in yourmix.exs
’ deps? – Razziaconfig/dev.exs
? ---config :rumbl, ecto_repos: [Rumbl.Repo]
, if not can you add it and try ecto migration then? – Mauricioconfig/config.exs
file but I tried it inconfig/dev.exs
also but got the same result unfortunately – Mileagemix.exs
has exactly those in the lock they come through as"postgrex": {:hex, :postgrex, "0.11.2", ...}
and"phoenix_ecto": {:hex, :phoenix_ecto, "3.0.1", ...}
– Mileage