Emu
Emu

Reputation: 5895

Elixir Cannot connect to the PostgreSQL

I've a project running on my local machine using:

Erlang with openssl: Version 18.0
Elixir: Version 1.3.4

I installed both of them using asdf. Everything works fine. But when I try to connect to database it always gives me the following error:

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

I'm using Ubuntu 18.04 and PostgreSQL 10. BTW, I can connect to the postgres using a Ruby on Rails project and it's working fine. I tried to remove the build and then mix deps.get && mix deps.compile, but still the same.

Any idea what's the issue?

UPDATE

mix.deps dependencies:

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

Upvotes: 1

Views: 773

Answers (1)

Emu
Emu

Reputation: 5895

I downgraded the postgres version from 10.7 to 9.5. It's working like a charm!

The version of postgrexadapter used in the project doesn’t have the upgrades to connect to PostgreSQL versions > 9.5.

Maybe it'll help someone else in future.

Thanks @AlekseiMatiushkin for your comment.

Upvotes: 1

Related Questions