AstonJ

AstonJ

'mix ecto.create' errors with: role "postgres" does not exist

Just posting this here in case it helps anyone else in future.

on mix ecto.create I was getting:

00:54:48.033 [error] GenServer #PID<0.214.0> terminating
** (Postgrex.Error) FATAL 28000 (invalid_authorization_specification) role "postgres" does not exist
    (db_connection) lib/db_connection/connection.ex:84: DBConnection.Connection.connect/2
    (connection) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: nil
State: Postgrex.Protocol
** (Mix) The database for Hello.Repo couldn't be created: killed

and psql was reporting:

psql: FATAL:  database "Aston" does not exist

See answer below…

Marked As Solved

AstonJ

AstonJ

Fixed with:

createdb 'Aston' 
psql

(Change Aston to whatever the psql command in the post above said was missing)

Then:

CREATE USER postgres SUPERUSER;
CREATE DATABASE postgres WITH OWNER postgres;
exit

(Although it told me the postgres db already exists - something you can check with psql -l)

mix ecto.create
$ The database for Hello.Repo has been created

:smiley:

19
Post #1

Also Liked

GenericJam

GenericJam

From here: https://stackoverflow.com/questions/15301826/psql-fatal-role-postgres-does-not-exist#comment-91332745

/usr/local/opt/postgres/bin/createuser -s postgres

Fixed it for me. The problem is homebrew doesn’t install the postgres user.

sbuffose

sbuffose

Hi guys! I got the same error:

16:05:28.295 [error] GenServer #PID<0.220.0> terminating
** (Postgrex.Error) FATAL 28000 (invalid_authorization_specification) no PostgreSQL user name specified in startup packet
    (db_connection) lib/db_connection/connection.ex:84: DBConnection.Connection.connect/2
    (connection) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: nil
State: Postgrex.Protocol
** (Mix) The database for Getaways.Repo couldn't be created: killed

and fixed it. It was due to the config on the dev.exs file (at the end of it):

Originally:

# Configure your database
config :getaways, Getaways.Repo,
  username: "postgres",
  password: "postgres",
  database: "getaways_dev",
  hostname: "localhost",
  pool_size: 10

Fixed:

# Configure your database
config :getaways, Getaways.Repo,
  username: "yourcomputeruser",
  password: "yourcomputeruser",
  database: "getaways_dev",
  hostname: "localhost",
  pool_size: 10

The setup by default is “postgres” => updated them to my computer user.

I hope it helps!

dimitarvp

dimitarvp

That’s kind of weird. PostgreSQL should always come with a created postgres user. I’d wager on a broken installation.

Last Post!

leifericf

leifericf

Thanks! I did indeed miss that part of the docs. And now it’s sorted!

Where Next?

Trending in Questions Top

jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
silverdr
Using Phoenix.LiveView.TagEngine as an EEx.Engine is deprecated! To compile HEEx, use Phoenix.LiveView.TagEngine.compile/2 instead. Sta...
New
saveman71
Hello ! We want new/edit form pages to POST/PUT to their own URL rather than the resources REST defaults (post /things, put /things/:id)...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New
michallepicki
I am using Oban and occasionally, shortly after a deployment, a handful of jobs can fail because of dependency on other parts of the syst...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge &amp; Solve. They are GUI (Emerge) and State management (S...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
akoutmos
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New

We're in Beta

About us Mission Statement