我有一个单独托管的Postgres数据库,我正在尝试使用我的Phoenix应用程序.我的prod配置是:
config :my_app,MyApp.Repo,adapter: Ecto.Adapters.Postgres,url: "postgres://username:password@myhost:5432/my_database",size: 20
当我的应用程序托管在Heroku上时,这工作正常,但是因为我已经将它移动到VPS,我不断收到此错误:
17:07:13.665 [info] GET /subjects 17:07:13.707 [info] Processing by MyApp.SubjectController.index/2 Parameters: %{"format" => "html"} Pipelines: [:browser,:authorize] 17:07:13.951 [error] GenServer #PID<0.515.0> terminating ** (exit) %Postgrex.Error{message: nil,postgres: %{code: :invalid_authorization_specification,file: "auth.c",line: "474",message: "no pg_hba.conf entry for host \"xxx.xxx.xxx.xxx\",user \"username\",database \"my_database\",SSL off",pg_code: "28000",routine: "ClientAuthentication",severity: "FATAL"}} 17:07:13.970 [info] Sent 500 in 305ms 17:07:13.972 [error] #PID<0.513.0> running MyApp.Endpoint terminated Server: xxx.xxx.xxx.xxx:80 (http) Request: GET /subjects ** (exit) exited in: GenServer.call(#PID<0.515.0>,{:query,"SELECT s0.\"id\",s0.\"name\",s0.\"inserted_at\",s0.\"updated_at\" FROM \"subjects\" AS s0",[]},5000) ** (EXIT) %Postgrex.Error{message: nil,severity: "FATAL"}}
我也可以从Postgres GUI工具连接到数据库,所以没有任何问题.我注意到的一件事是它将我的VPS IP声明为主机而不是url中指定的主机.
这应该没关系,因为数据库完全在一个单独的主机上,但我仍然在这里尝试了解决方案:
> No pg_hba.conf entry for host
> Connect to PostgreSQL server: FATAL: no pg_hba.conf entry for host
真的很挣钱,请帮忙!
更新:这是我的pg_hba.conf:
# TYPE DATABASE USER ADDRESS METHOD # "local" is for Unix domain socket connections only local all all peer # IPv4 local connections: host all all 127.0.0.1/32 md5 # IPv6 local connections: host all all ::1/128 md5 # Allow replication connections from localhost,by a user with the # replication privilege. #local replication postgres peer #host replication postgres 127.0.0.1/32 md5 #host replication postgres ::1/128 md5 host all all 0.0.0.0/0 md5
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。