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…
Trending in Questions
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
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
Using Phoenix.LiveView.TagEngine as an EEx.Engine is deprecated!
To compile HEEx, use Phoenix.LiveView.TagEngine.compile/2 instead.
Sta...
New
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
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app?
Looking for hints regarding:
Addi...
New
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
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
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
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
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
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
@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
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #elixirconf-us
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #performance
- #security










First 10 of 23 Posts!
AstonJ
Fixed with:
(Change
Astonto whatever thepsqlcommand in the post above said was missing)Then:
(Although it told me the postgres db already exists - something you can check with
psql -l)dimitarvp
That’s kind of weird. PostgreSQL should always come with a created
postgresuser. I’d wager on a broken installation.AstonJ
Yeah something weird is going on. I haven’t done a clean install for a while, just update after (MacOS) update - I generally hate settling with updates as things always break and start to feel sluggish after a while. But Apple being Apple have made clean installs harder - last time a clean install totally broke my email settings and I had to report it as a bug to get an answer on fixing it!
I’ll only do a clean install now if I have a week or two spare 
Reason I posted the thread here is because when searching I noticed someone had commented they got the same error after running
mix ecto.createtoo! So thought having it more easily and directly google-able might help others in futureshanesveller
Agreed, but the Homebrew installation creates a SQL user named after your OS user and no “postgres” user to go with it. Just something to document and be aware of like @AstonJ has done here
AstonJ
Ah that explains why when using Rails it works fine - because I guess they use your account name user rather than ‘postgres’.
I wonder if Ecto could detect whether you’re using OSX and do the same? Otherwise every Mac user who have installed PG via homebrew will get the same.
Alternatively maybe hombrew could create the postgres role on installation too?
shanesveller
So for me the disconnect is that the generators hard-code the literal value of “postgres” for username on the Ecto connection, but really what it needs is a SQL user that is a superuser or that has DB creation rights. I would prefer some explicitness/agnosticism in that direction be included in the Phoenix generator output, and/or in the Hex docs, instead of assuming I’ve left the default “postgres” user intact and with superuser privileges.
I don’t do that on my dev workstation or my production DB either, so I wind up using a Repo.init/2 callback and a DATABASE_URL basically immediately on new projects.
dimitarvp
Not sure. I installed PG through homebrew as well and I seem to remember it having the postgres user and a fresh Phoenix app working right away. But then again, that was a while ago, can’t swear the details on my life.
As for the Ecto default, you’re not wrong but then again they apply for local-only config so I see no harm done.
axelson
But if you’re working on a shared project, you’re probably better off with everyone using the
postgresuser locally, or not setting one at all (which I think will default to the logged in user)sbuffose
Hi guys! I got the same error:
and fixed it. It was due to the config on the dev.exs file (at the end of it):
Originally:
Fixed:
The setup by default is “postgres” => updated them to my computer user.
I hope it helps!
dimitarvp
I’m thinking you need to have a look at your
pg_hba.confand make sure you are actually permitted to log into Postgres.Have you tried getting in simply with
psql -U postgres?Last Post!
leifericf
Thanks! I did indeed miss that part of the docs. And now it’s sorted!