I read a little about that but it still doesn’t work.
To create container and expose port I used command:
docker run --name postgres_db -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 -d postgres
Using those credentials and IPHost provided while inspecting container I could go into server in pgadmin4. Basically it works.
Now the part that doesn’t work with Elixir
dev.exs
config :weather, Weather.Repo,
username: "postgres",
password: "postgres",
hostname: "postgres_db",
port: 5432,
database: "weather_dev",
stacktrace: true,
show_sensitive_data_on_connection_error: true,
pool_size: 10
As you can see. Credentials are the same. Hostname is container name in this case:
Obviously i got:
14:13:27.670 [error] Postgrex.Protocol (pid<0.211.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (postgres_db:5432): non-existing domain - :nxdomain
I changed hostname to localhost:
FORMATTER ERROR: bad return value
14:14:18.846 [debug] ** (RuntimeError) bad return value from Logger formatter Logger.Formatter, got [[<<179, 101, 109, 32, 110, 105, 101, 32, 112, 111, 119, 105, 111, 100, 179, 97, 32, 115, 105, 234, 32, 100, 108, 97, 32, 117, 191, 121, 116, 107, 111, 119, 110, 105, 107, 97, 32, 34, 112, 111, 115, 116, 103, 114, 101, 115, 34>>, “\n”] | “\e[0m”] after “\e[31m\n14:14:18.843 [error] Postgrex.Protocol (pid<0.416.0>) failed to connect: ** (Postgrex.Error) KATASTROFALNY 28P01 (invalid_password) autoryzacja has”
(kernel 9.0.2) logger_h_common.erl:430: :logger_h_common.string_to_binary/1
(kernel 9.0.2) logger_h_common.erl:396: :logger_h_common.do_log_to_binary/2
(kernel 9.0.2) logger_h_common.erl:177: :logger_h_common.log/2
(kernel 9.0.2) logger_backend.erl:51: :logger_backend.call_handlers/3
(db_connection 2.6.0) lib/db_connection/connection.ex:110: DBConnection.Connection.handle_event/4
(stdlib 5.0.2) gen_statem.erl:1379: :gen_statem.loop_state_callback/11
(stdlib 5.0.2) proc_lib.erl:241: :proc_lib.init_p_do_apply/3FORMATTER ERROR: bad return value
14:14:18.881 [debug] ** (RuntimeError) bad return value from Logger formatter Logger.Formatter, got [[<<179, 101, 109, 32, 110, 105, 101, 32, 112, 111, 119, 105, 111, 100, 179, 97, 32, 115, 105, 234, 32, 100, 108, 97, 32, 117, 191, 121, 116, 107, 111, 119, 110, 105, 107, 97, 32, 34, 112, 111, 115, 116, 103, 114, 101, 115, 34>>, “\n”] | “\e[0m”] after “\e[31m\n14:14:18.881 [error] Postgrex.Protocol (pid<0.424.0>) failed to connect: ** (Postgrex.Error) KATASTROFALNY 28P01 (invalid_password) autoryzacja has”
(kernel 9.0.2) logger_h_common.erl:430: :logger_h_common.string_to_binary/1
(kernel 9.0.2) logger_h_common.erl:396: :logger_h_common.do_log_to_binary/2
(kernel 9.0.2) logger_h_common.erl:177: :logger_h_common.log/2
(kernel 9.0.2) logger_backend.erl:51: :logger_backend.call_handlers/3
(db_connection 2.6.0) lib/db_connection/connection.ex:110: DBConnection.Connection.handle_event/4
(stdlib 5.0.2) gen_statem.erl:1379: :gen_statem.loop_state_callback/11
(stdlib 5.0.2) proc_lib.erl:241: :proc_lib.init_p_do_apply/3** (Mix) The database for Weather.Repo couldn’t be created: killed
Error is different - result the same. No connection.
It looks like it tries to go into my local instance of postgres but there are invalid credentials for that.
I dont know how it’s supposed to be working with localhost if its signed to local machine and not docker even if i exposed port and it should be working.
I am out of ideas for a now.


















