Running the following starts up the Postgres docker image:
docker run --name postgres -e POSTGRES_DB=vapor -e POSTGRES_USER=vapor -e POSTGRES_PASSWORD=password -p 5432:5432 -d postgres
Settings up the config:
var databases = DatabaseConfig()
let databaseConfig = PostgreSQLDatabaseConfig(hostname: “localhost”, username: “vapor”, database: “vapor”, password: “password”)
let database = PostgreSQLDatabase(config: databaseConfig)
databases.add(database: database, as: .psql)
Gives the the following error:
️ [PostgreSQLError.trust: No password is required]
[Async] Warning: read triggered when input queue was empty, ignoring: error(️ PostgreSQL Diagnostic: FATAL: role “vapor” does not exist
- id: PostgreSQLDiagnosticResponse.InitializeSessionUserId
Here are some possible causes:
- role “vapor” does not exist
Program ended with exit code: 1
Is the chapter missing a step? Or do I have a typo somewhere?
@warplydesigned if you stop the docker container (
docker stop postgres) do you still get the same error? I’ve seen this error before with people who’ve installed Postgres with brew or manually and have the service running locally as well as the Docker container.
@0xtim thanks that must be the issue. I’m on my other computer right now away from home but it worked on the MacBook I have here as described in the book.
I’ve got the same issue. I did set everything up as in the book, but for some reason I can’t get it to work. I always get this error:
Thread 1: Fatal error: Error raised at top level: ️ PostgreSQL Error: No password is required
I already deleted every other docker image and PostgreSQL from my Mac, did the “Xcode Dance” (delete Derived Data, Clean and Clean Build Folder). Still nothing. It works in the cloud though.
Alright, I’ll just leave this here as a reference:
I just restarted my Mac and ran
vapor clean, followed by
vapor xcode -y. Seems to have solved the issue.
My issue was related to brew had Postgres also installed when I stopped the brew version the instructions in the book worked.
i hace encounter the same error i have use this suggestion but still getting the same error .
@swiftios if your stop the Docker container do you get the same error?
i got the same error even i shutdown the docker container.
catching the error this what i got.
That means you have another instance of Postgres running somewhere - have you installed it via home-brew or an app or something?
You can do
lsof -i :5432 to find the process and then kill it. Then start the Docker container and it should work
Thanks for you help. the way i solved i reset the Docker it’s was the only way to make it work.
I have added a postgres database and deployed project on vapor cloud. Without DB this worked fine, but now i get 503 error in response.
Can someone help me ?
If you redeploy and then do
vapor cloud logs --since=2h what does it show?
Docker has somehow started two instances and always does for me? I am using the code of the book and it results in the same error. I can restart Docker as often as I want, but so far nothing in this thread helped me out. So sorry that I have to review this thread. This ist the result of the „lsof -i“.
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
com.docke 50830 atrust 21u IPv4 0x4b76a8dee64ab571 0t0 TCP *:postgresql (LISTEN)
com.docke 50830 atrust 22u IPv6 0x4b76a8def606eab1 0t0 TCP localhost:postgresql (LISTEN)
Hey @sajonara how do you know it creates two instances? The output of
lsof there shows the same instance connected over both IPv4 and IPv6. What does
docker ps show?
Thx, @0xtim. I thought it does but those are just ipv4 and ipv6 for the same process, there are no other sessions as docker ps shows, but the error is persistent, and as it seems it is there for quite some time, regarding version history of the involved apps ^^.
Where should I start to debug? Because I tried different versions of macOS and Xcode… as I thought maybe it was the Beta version of one Xcode I used which resulted in this error, but it had nothing to do with it, it is just the same on several systems.
I googled the error message and found only a handful of results, one of them was this thread. I tried redoing the whole project and even upgrading postgresql, etc. So far I changed back to SQLite, and will check on the topic regularly, if a solution comes up.
What is the full error message?
If you kill Docker do you get the same error message or a different one (like do you have another instance of Postgres installed outside of Docker)
@0xtim I looked for another installation of postgresql but I have none installed via brew. I checked that. The error message is identical to the one posted by @thedan84.
If I stop the Docker container it complains about not being able to connect to the postgresql db. So at least I know that it tries to connect.
How are you starting the Docker container? If you stop the Docker container, does anything appear in
By any chance have you installed macOS server? If you did that also has an instance of Postgres.