4

I use Prisma with Cloud Run & Cloud SQL. After providing DATABASE_URL to the prisma.schema it throws me an error in runtime.

Can't reach database server at `(/cloudsql/project-name:us-east1:database-id)`:`5432`
Please make sure your database server is running at `(/cloudsql/project-name:us-east1:database-id)`:`5432`."
  • Database: Postgres
  • Provided url DATABASE_URL: postgresql://username:password@localhost/databasename?host=(/cloudsql/project-name:us-east1:database-id)

What is wrong with connection? Do I failed to construct DATABASE_URL correctly?

2
  • Show your Cloud Run deployment and the deployment command. Commented Jun 14, 2021 at 21:13
  • @JohnHanley I was able to manage this issue on my own. The problem was in brackets around the host parameter in the connection URL. I posted my solution as an answer to the question. Commented Jun 14, 2021 at 21:14

1 Answer 1

9

I removed brackets () around host parameter /cloudsql/project-name:us-east1:database-id and everything start to work as expected.

Before (with brackets)

postgresql://username:password@localhost/databasename?host=(/cloudsql/project-name:us-east1:database-id)

After (without brackets)

postgresql://username:password@localhost/databasename?host=/cloudsql/project-name:us-east1:database-id
Sign up to request clarification or add additional context in comments.

1 Comment

For anyone who still has an error, my issue was incorrectly trying to connect to the "postgres" database. Create a new database for application data as suggested here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.