FATAL: permission denied for database "postgres"


#1

Last night, my application server suddenly started getting errors with every prisma request. I went to the GraphQL playground to test directly with my prisma server if I would also get errors there, and I did. They looked like this:

“message”: “Whoops. Looks like an internal server error. Search your server logs for request ID: local:cjueenue2001t0701jys8h26v”

To check the server logs on heroku, I did this:

$ heroku run bash -a

The errors look like this:

Apr 12, 2019 6:29:43 PM org.postgresql.Driver connect
SEVERE: Connection error:
org.postgresql.util.PSQLException: FATAL: permission denied for database “postgres”
Detail: User does not have CONNECT privilege.
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2433)
at org.postgresql.core.v3.QueryExecutorImpl.readStartupMessages(QueryExecutorImpl.java:2566)
at org.postgresql.core.v3.QueryExecutorImpl.<init>(QueryExecutorImpl.java:131)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:210)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:195)
at org.postgresql.Driver.makeConnection(Driver.java:452)
at org.postgresql.Driver.connect(Driver.java:254)
at slick.jdbc.DriverDataSource.getConnection(DriverDataSource.scala:101)
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:341)
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:193)
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:430)
at com.zaxxer.hikari.pool.HikariPool.access$500(HikariPool.java:64)
at com.zaxxer.hikari.pool.HikariPool$PoolEntryCreator.call(HikariPool.java:570)
at com.zaxxer.hikari.pool.HikariPool$PoolEntryCreator.call(HikariPool.java:563)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

I searched for a solution to this problem, and I found this GitHub issue:

There was no solution to the problem there or anywhere else in my search results. The data in my database is not important, since the web app is in a prototype stage, but this was preventing the web app from working, so I decided to start completely from scratch, following the instructions in this video, as I did originally several months ago:

I thought for sure that this would fix the problem, since I started over completely, but unfortunately I still get the exact same errors with the brand new prisma server, service, and database.

My prisma version is:
prisma/1.30.1 (darwin-x64) node-v8.12.0

Please help. Thank you!


#2

I have reproduced this problem with the following datamodel.prisma:

type User {
id: ID! @unique
name: String!
}


#3

I was able to get past this problem by removing my Heroku account from “Heroku CONNECTED ACCOUNTS” in the Prisma console, and then recreating my Prisma server, database, and service from scratch. That’s definitely the nuclear option, which I would never want to do with a production web app, but in this case I just wanted to get my prototype web app back and running again ASAP.

I still have no idea why this problem randomly started happening when my prototype web app has successfully used Prisma with Heroku for several months.

If there is a less severe way of fixing this, please let me know, for future reference.


#4

This was the discussion that helped me get it working.