Phoenix 无法连接到 Heroku 的 PostgreSQL 服务器

dsp*_*099 3 postgresql elixir ecto phoenix-framework

这是我在我设置来搞乱的原始 Phoenix 应用程序上看到的错误:

[错误] Postgrex.Protocol (#PID<0.362.0>) 无法连接:** (Postgrex.Error) FATAL 28000 (invalid_authorization_specation): 没有主机“24.25.201.68”、用户“koilqmnaakvfjg”的 pg_hba.conf 条目,数据库“dc245o0vlbprf7”,SSL 关闭

这是我的config/dev.exs

# Configure your database
config :hello, Hello.Repo,
  adapter: Ecto.Adapters.Postgres,
  username: "koilqmnaakvfjg",
  password: "somepass",
  database: "dc245o0vlbprf7",
  hostname: "ec2-54-243-54-6.compute-1.amazonaws.com",
  pool_size: 10
Run Code Online (Sandbox Code Playgroud)

我缺少一些简单的东西吗?

编辑:

我的 pg_hba.conf 文件如下所示:

# TYPE  DATABASE        USER            ADDRESS                 METHOD
host  all  all 0.0.0.0/0 md5
# "local" is for Unix domain socket connections only
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
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     trust
host    replication     all             127.0.0.1/32            trust
host    replication     all             ::1/128                 trust
Run Code Online (Sandbox Code Playgroud)

sBa*_*nda 5

您需要将 ssl 参数设置为 true,如果问题仍然存在,请修改 pg_hba.conf 文件。

解决方案:

# Configure your database
config :hello, Hello.Repo,
  adapter: Ecto.Adapters.Postgres,
  username: "koilqmnaakvfjg",
  password: "somepass",
  database: "dc245o0vlbprf7",
  hostname: "ec2-54-243-54-6.compute-1.amazonaws.com",
  pool_size: 10,
  ssl: true
Run Code Online (Sandbox Code Playgroud)

希望有帮助:D

向我通报进展情况;

祝你好运;