The Problem
I am following the Getting Started Guide at https://hexdocs.pm/ecto/getting-started.html, trying to set up in a docker container. The steps in the guide work on my physical machine, but when I follow them for the container, I get the following error when I run mix ecto.create
at the appropriate step:
04:48:05.579 [error] GenServer #PID<0.177.0> terminating
** (RuntimeError) Connect raised a FunctionClauseError error. The exception details are hidden, as
they may contain sensitive data such as database credentials.
(postgrex) lib/postgrex/messages.ex:371: Postgrex.Messages.decode_auth_type/1
(postgrex) lib/postgrex/messages.ex:64: Postgrex.Messages.parse/3
(postgrex) lib/postgrex/protocol.ex:2004: Postgrex.Protocol.msg_decode/1
(postgrex) lib/postgrex/protocol.ex:1978: Postgrex.Protocol.msg_recv/3
(postgrex) lib/postgrex/protocol.ex:589: Postgrex.Protocol.auth_recv/3
(postgrex) lib/postgrex/protocol.ex:504: Postgrex.Protocol.handshake/2
(db_connection) lib/db_connection/connection.ex:135: DBConnection.Connection.connect/2
(connection) lib/connection.ex:622: Connection.enter_connect/5
Last message: nil
** (Mix) The database for Friends.Repo couldn't be created: an exception was raised:
** (RuntimeError) Connect raised a FunctionClauseError error. The exception details are hidden, as
they may contain sensitive data such as database credentials.
(postgrex) lib/postgrex/messages.ex:371: Postgrex.Messages.decode_auth_type/1
(postgrex) lib/postgrex/messages.ex:64: Postgrex.Messages.parse/3
(postgrex) lib/postgrex/protocol.ex:2004: Postgrex.Protocol.msg_decode/1
(postgrex) lib/postgrex/protocol.ex:1978: Postgrex.Protocol.msg_recv/3
(postgrex) lib/postgrex/protocol.ex:589: Postgrex.Protocol.auth_recv/3
(postgrex) lib/postgrex/protocol.ex:504: Postgrex.Protocol.handshake/2
(db_connection) lib/db_connection/connection.ex:135: DBConnection.Connection.connect/2
(connection) lib/connection.ex:622: Connection.enter_connect/5
The Situation/Configuration
I have set up Postgres in my docker container so that the postgres
user has a password, and I have used that password in the config/config.exs
file. I know the password works, as I can use psql
with it. The config file mentioned looks like this:
use Mix.Config
config :friends, Friends.Repo,
adapter: Ecto.Adapters.Postgres,
database: "friends_repo",
username: "postgres",
password: "<password>",
hostname: "localhost"
config :friends, ecto_repos: [Friends.Repo]
Now, since there is always a request for the pg_hba.conf
file in similar situations, I provide that below. (As this is a development machine, I am less concered about security than I am about getting something working in the first place.)
local all postgres md5
# 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 all peer
host replication all 127.0.0.1/32 md5
host replication all ::1/128 md5
Finally, the following are the versions of related applications and tools.
Postgres
version
-----------------------------------------------------------------------------------------------------------------------------
PostgreSQL 10.5 (Ubuntu 10.5-0ubuntu0.18.04) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 7.3.0-16ubuntu3) 7.3.0, 64-bit
Elixir
Erlang/OTP 21 [erts-10.0.5] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]
Elixir 1.7.2 (compiled with Erlang/OTP 20)
Running Command: mix deps.update
Resolving Hex dependencies...
Dependency resolution completed:
Unchanged:
connection 1.0.4
db_connection 1.1.3
decimal 1.5.0
ecto 2.2.10
poolboy 1.5.1
postgrex 0.13.5
Final Notes
I’ve read similar topics and problems on this forum, on github, and other places found from Google, but the answers I found did not help. Thus, my hope is that someone here can provide some direction and help get things working.
Thank you in advance.