我有一个项目在我的本地机器上运行,使用:
Erlang with openssl: Version 18.0
Elixir: Version 1.3.4
我使用 asdf 安装了它们。一切正常。但是当我尝试连接到数据库时,它总是给我以下错误:
unhandled exit at GET /ad_units/Y9Gd1kAiPCv8WOrE exited in: :gen_server.call(#PID<0.469.0>, {:checkout, #Reference<0.0.6.2529>, true, 15000}, 5000) ** (EXIT) an exception was raised: ** (CaseClauseError) no case clause matching: [10, 7, 7, 18, 4, 1] (postgrex) lib/postgrex/utils.ex:39: Postgrex.Utils.parse_version/1 (postgrex) lib/postgrex/extensions/void.ex:5: Postgrex.Extensions.Void.init/2 (postgrex) lib/postgrex/types.ex:56: anonymous fn/2 in Postgrex.Types.prepare_extensions/2 (elixir) lib/enum.ex:1115: anonymous fn/4 in Enum.into/3 (elixir) lib/enum.ex:1623: Enum."-reduce/3-lists^foldl/2-0-"/3 (elixir) lib/enum.ex:1121: Enum.into/4 (postgrex) lib/postgrex/protocol.ex:434: Postgrex.Protocol.bootstrap_send/3 (postgrex) lib/postgrex/protocol.ex:69: Postgrex.Protocol.connect/1 (db_connection) lib/db_connection/connection.ex:114: DBConnection.Connection.connect/2 (connection) lib/connection.ex:623: Connection.enter_connect/5 (stdlib) proc_lib.erl:239: :proc_lib.init_p_do_apply/3
我使用的是 Ubuntu 18.04 和 PostgreSQL 10。
顺便说一句,我可以使用 Ruby on Rails 项目连接到 postgres,它工作正常。我尝试删除 build
然后删除 mix deps.get && mix deps.compile
,但还是一样。
知道问题出在哪里吗?
更新
mix.deps
依赖:
defp deps do
[{:phoenix, "~> 1.1.6"},
{:postgrex, ">= 0.0.0"},
{:phoenix_ecto, "~> 2.0"},
{:phoenix_html, "~> 2.4"},
{:phoenix_live_reload, "~> 1.0"},
{:gettext, "~> 0.9"},
{:cowboy, "~> 1.0"},
{:phoenix_slime, "~> 0.6.0"},
{:timex, "~> 2.2"},
{:tzdata, "~> 0.1.8", override: true},
{:timex_ecto, "~> 1.1.3"},
# {:quantum, ">= 1.7.1"},
{:exrm, "~> 1.0" },
{:edeliver, ">= 1.2.10"},
{:browser, "~> 0.1.0"}]
end
最佳答案
我将 postgres 版本从 10.7 降级到 9.5。它就像一个魅力!
项目中使用的 postgrex
适配器版本没有升级到 PostgreSQL> 9.5 版本。
也许将来它会对其他人有所帮助。
感谢@AlekseiMatiushkin 的评论。
关于postgresql - Elixir 无法连接到 PostgreSQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55643426/