Patoshizzle

Patoshizzle

(Postgrex.Error) FATAL 28P01 (invalid_password) password authentication failed for user “postgres”

After calling mix ecto.create I get this error:

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

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

I thought the database creates the default user postgres are created automatically, why would it fail
authentication. The password according to the config files is postgres

Thanks! :smiley:

Most Liked

silverdr

silverdr

FWIW - I just tried to set a quick test project up and I recalled the discussion here so I thought I’d check it. Therefore I left both user and password at the default “postgres” and encountered the same issue/errors OP described in his first post. The solution in my case:

silverdr$ sudo -u postgres psql
psql (12.9 (Ubuntu 12.9-0ubuntu0.20.04.1))
Type "help" for help.

postgres=# \password postgres
Enter new password: 
Enter it again: 
postgres=# \q
silverdr$ mix ecto.create
Compiling 29 files (.ex)
Generated testapp app
The database for Testapp.Repo has been created

IOW - altering the ROLE “postgres” to have password “postgres” helped immediately. This is basically the same what @inko mentioned: if you want to use the “postgres” role, give it the password you have cofigured in the Elixir application config.

silverdr

silverdr

You need to check what “ROLES” your Postgres installation has available, and possibly create a suitable one. PostgreSQL docs say:

In order to bootstrap the database system, a freshly initialized system always contains one predefined role. This role is always a “superuser”, and by default (unless altered when running initdb ) it will have the same name as the operating system user that initialized the database cluster. Customarily, this role will be named postgres .

This means it is neither guaranteed for every PostgreSQL installation to have the postgres “role” nor it is guaranteed for it to have “postgres” as password, even if it exists.

Patoshizzle

Patoshizzle

I have confirmed thru \du that indeed a user postgres exists, i created (i am not sure if actually ecto was the one supposed to create) a database with the same name in the dev.exs in the config directory and logged in using the password postgress and the log in was successful.

I returned to my elixir/phoenix app and run mix ecto.create and the same error “password authentication failed for user postgres”.

Any other hint or solution is welcome.

Where Next?

Popular in Questions Top

sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New

Other popular topics Top

malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36128 110
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 47930 226
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New

We're in Beta

About us Mission Statement