我正在开始我的 Elixir/Phoenix 之旅,但我的 postgres 连接遇到了一些问题。
当我启动我的服务器时,我得到:
$ 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
作为 Elixir、Phoenix 和 Ecto 的新手,我不清楚如何调试这个问题。任何关于我的问题是什么或我如何调试它的建议将不胜感激。
我的应用程序已设置
我有一个基本的应用程序
mix phoenix.new rumbl
cd rumbl
mix deps.get
mix deps.compile
我的 config/dev.exs 具有以下数据库设置
# Configure your database
config :rumbl, Rumbl.Repo,
adapter: Ecto.Adapters.Postgres,
username: "elixir",
database: "rumbl_dev",
hostname: "localhost",
pool_size: 10
当我运行mix ecto.create
时没有错误,我可以看到我在 psql 中rumbl_dev
运行的时间。\l
它也归 elixir 用户所有。
运行mix ecto.migrate
会引发相同的连接错误
我的 pg_hba.conf 文件有以下内容
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
这是我使用 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=>