1

Following the standard procedure to create a new Phoenix/Elixir project. However, encounter error during installation. Please comment how to solve this error.

0. Setting

$ node -v
v14.18.1

$ npm -v
6.14.15

$ elixir -v
Erlang/OTP 24 [erts-12.1.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit] [dtrace]
Elixir 1.12.3 (compiled with Erlang/OTP 24)

$ mix phx.new --version
Phoenix installer v1.6.2

1. Create a folder to persist the DB data.

mkdir ${HOME}/phoenix-postgres-data/

2. Run a Docker container with the Postgres image.

$ docker run -d \
 --name phoenix-psql \
 -e POSTGRES_PASSWORD=Phoenix1234 \
 -v ${HOME}/phoenix-postgres-data/:/var/lib/postgresql/data \
 -p 5432:5432 \
 postgres

3. Validate that the container is running.

$ docker ps
CONTAINER ID   IMAGE      COMMAND                  CREATED       STATUS         PORTS                                       NAMES
fca9fbc140e6   postgres   "docker-entrypoint.s…"   4 hours ago   Up 6 minutes   0.0.0.0:5432->5432/tcp, :::5432->5432/tcp   phoenix-psql

4. Creating a New Project

$ mix phx.new pento --live
* creating pento/config/config.exs
* creating pento/config/dev.exs
* creating pento/config/prod.exs
* creating pento/config/runtime.exs
...
* creating pento/priv/static/favicon.ico

Fetch and install dependencies? [Yn] Y
* running mix deps.get
* running mix deps.compile

5. Finishing touch

$ cd pento
$ mix ecto.create && mix phx.server && iex -S mix phx.server

Error Message

Compiling 14 files (.ex)
Generated pento app

18:47:31.378 [error] GenServer #PID<0.411.0> terminating
** (Postgrex.Error) FATAL 28P01 (invalid_password) password authentication failed for user "postgres"
    (db_connection 2.4.0) lib/db_connection/connection.ex:100: DBConnection.Connection.connect/2
    (connection 1.1.0) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib 3.16.1) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Last message: nil
State: Postgrex.Protocol

18:47:31.423 [error] GenServer #PID<0.419.0> terminating
** (Postgrex.Error) FATAL 28P01 (invalid_password) password authentication failed for user "postgres"
    (db_connection 2.4.0) lib/db_connection/connection.ex:100: DBConnection.Connection.connect/2
    (connection 1.1.0) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib 3.16.1) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Last message: nil
State: Postgrex.Protocol
** (Mix) The database for Pento.Repo couldn't be created: killed
Adam Millerchip
  • 20,844
  • 5
  • 51
  • 74
madeinQuant
  • 1,721
  • 1
  • 18
  • 29
  • Did you update the `config/dev.exs` (and others?) with the proper database credentials? Are you able to log into the database independently e.g. using psql CLI or PSequel? – Everett Oct 13 '21 at 11:41

1 Answers1

3

The database must be configured for . Make sure you have something like the lines below in your config/config.exs

config :my_app, MyApp.Repo,
  adapter: Ecto.Adapters.Postgres,
  username: "postgres",
  password: "Phoenix1234",
  database: "my_app_dev",
  hostname: "localhost",
  pool_size: 10

or. alternatively, set the password in docker postgres to be empty.

Aleksei Matiushkin
  • 119,336
  • 10
  • 100
  • 160