prisma-heroku icon indicating copy to clipboard operation
prisma-heroku copied to clipboard

Database connection issues

Open marano opened this issue 6 years ago • 16 comments

Hi, thank you for writing this up!

I've been following this in order to deploy to Heroku and found some issues when connecting to the database. These are the issues I'm seeing.

When the server starts I get:

SEVERE: Connection error:
org.postgresql.util.PSQLException: FATAL: permission denied for database "postgres"
Detail: User does not have CONNECT privilege.

This is very weird, because I passing a database name which is not postgres. And then later I start getting the error:

SEVERE: Connection error:
org.postgresql.util.PSQLException: FATAL: too many connections for role "nfcsdwxwnplgnf"

This second error makes more sense, because it informs the correct user I am using to connect. But since Heroku Postgres database has a connection cap for 20, there is not much I can do to solve this. Is there a way to set Prisma connection pool max connections?

With my deployment I am able to run prisma deploy and see that my tables were created. But I can't query the Graphql API because of the connection errors.

marano avatar Jun 02 '18 05:06 marano

@marano Sorry for being absent here. Did you manage to fix the issue?

dpetrick avatar Oct 05 '18 13:10 dpetrick

@dpetrick Hey Dominic, thank you for your response. I decided not to use prisma at the time because it seemed too resource greed. Beside the too many connections issues I was also getting out of memory errors on the server.

For the database too many connections issue it seems that now you can specify the pool size via an environment variable.

marano avatar Oct 05 '18 13:10 marano

I'm having the same issue

seawatts avatar Feb 09 '19 21:02 seawatts

Hello, I'm having same issue too.

devniel avatar Mar 18 '19 03:03 devniel

I am having the same issue. Any update on this issue?

bobsingor avatar Apr 02 '19 21:04 bobsingor

I am reopening this issue since so many people are getting stuck with it.

marano avatar Apr 04 '19 15:04 marano

Any updates on this? Having this issue too, where/when is the prisma deploy executed? That seems to be the problem...

Thanks in advance!

trufa avatar Apr 06 '19 19:04 trufa

I seemed to have solved that issue with heroku pg:reset

trufa avatar Apr 06 '19 19:04 trufa

@trufa Could you please told us your steps, please? I did the pg:reset comand but no luck

Thank you!

Fabiomad85 avatar Apr 07 '19 08:04 Fabiomad85

I'm having this issue as well.

dylancm4 avatar Apr 12 '19 05:04 dylancm4

Because this has completely broken my web app, but my data was not important because I'm in alpha, I completely recreated from scratch the entire prisma server, database, and service on heroku. I thought for sure this would fix the problem. It didn't. I still see the "User does not have CONNECT privilege" error below. Please help.

Running bash on ⬢ desolate-dusk-32165... up, run.9920 (Hobby) Apr 12, 2019 6:23:18 PM org.postgresql.core.v3.ConnectionFactoryImpl log WARNING: SQLException occurred while connecting to ec2-23-23-80-20.compute-1.amazonaws.com:5432 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.(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.(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)

dylancm4 avatar Apr 12 '19 18:04 dylancm4

I was able to get it working, though there is likely a better way than everything I went through, essentially starting over from scratch with Heroku. https://www.prisma.io/forum/t/fatal-permission-denied-for-database-postgres/6677/2

dylancm4 avatar Apr 13 '19 18:04 dylancm4

Don't think it's a bulletproof solution, but I seemed to solve this issue by running a deploy on the database.

Importantly: the issue doesn't seem to be one of using incorrect credentials / using incorrect environment variables. I could get into the database using Postico & the exact same credentials (triple-checked against the ones Prisma was given as env vars). The problem only relented after deploying, in my case.

AWebOfBrown avatar May 02 '19 05:05 AWebOfBrown

I'm getting this issue again today after running a deleteMany___s mutation to delete a large number of objects. Every single query now fails with:

WARNING: SQLException occurred while connecting to ec2-50-19-127-115.compute-1.amazonaws.com:5432 org.postgresql.util.PSQLException: FATAL: permission denied for database "postgres" Detail: User does not have CONNECT privilege.

dylancm4 avatar May 03 '19 09:05 dylancm4

Any update? I've been getting the same errors and have spent hours trying to figure it out. I don't want to recreate everything from scratch :/

nlitwin avatar Jul 06 '19 02:07 nlitwin

FYI: This repository is just an example and I don't think there is anyone really looking into it. We need this issue to be raised at the prisma repository or at their Slack channels.

marano avatar Jul 10 '19 11:07 marano