peppermint icon indicating copy to clipboard operation
peppermint copied to clipboard

Prisma Error P1013

Open jvdutrag opened this issue 1 year ago • 7 comments
trafficstars

I am running the dockerized version. The application is not connecting to the database / running migrations apparently.

eppermint | Environment variables loaded from .env peppermint | Prisma schema loaded from src/prisma/schema.prisma peppermint | Datasource "db": PostgreSQL database peppermint | {"level":50,"time":1711761602379,"pid":148,"hostname":"8c3de868bbd6","err":{"type":"Error","message":"Command failed: npx prisma migrate deploy\nError: P1013: The provided database string is invalid. empty host in database URL. Please refer to the documentation in https://www.prisma.io/docs/reference/database-reference/connection-urls for constructing a correct connection string. In some cases, certain characters must be escaped. Please check the string for any illegal characters.\n","stack":"Error: Command failed: npx prisma migrate deploy\nError: P1013: The provided database string is invalid. empty host in database URL. Please refer to the documentation in https://www.prisma.io/docs/reference/database-reference/connection-urls for constructing a correct connection string. In some cases, certain characters must be escaped. Please check the string for any illegal characters.\n\n at ChildProcess.exithandler (node:child_process:422:12)\n at ChildProcess.emit (node:events:518:28)\n at maybeClose (node:internal/child_process:1105:16)\n at ChildProcess._handle.onexit (node:internal/child_process:305:5)","code":1,"killed":false,"signal":null,"cmd":"npx prisma migrate deploy"},"msg":"Command failed: npx prisma migrate deploy\nError: P1013: The provided database string is invalid. empty host in database URL. Please refer to the documentation in https://www.prisma.io/docs/reference/database-reference/connection-urls for constructing a correct connection string. In some cases, certain characters must be escaped. Please check the string for any illegal characters.\n"}

jvdutrag avatar Mar 30 '24 01:03 jvdutrag

can you provide an example of your docker-compose?

potts99 avatar Mar 30 '24 10:03 potts99

can you provide an example of your docker-compose?

I'm using the one provided on docs, just changed password and API URL.

jvdutrag avatar Mar 30 '24 16:03 jvdutrag

if you do docker ps -a, is postgres container running for you? @jvdutrag if not check docker logs postgres, it might say not enough space

potts99 avatar Mar 30 '24 23:03 potts99

The error message sounds like the database host is empty.

The provided database string is invalid. empty host in database URL.

skdishansachin avatar Mar 31 '24 05:03 skdishansachin

I also had a similar problem on the npx prisma migrate ... command but it was P102X (big dumb dumb me did not have it anymore... but a DB thing also) but after some tinkering, I created a apps/api/.env file in with the following content :

DB_USERNAME=user
DB_PASSWORD=pass
DB_HOST=peppermint_db_service_in_docker_file
DB_NAME=peppermint
DATABASE_URL=postgres://${DB_USERNAME}:${DB_PASSWORD}@${DB_HOST}/${DB_NAME}

and npx prisma commands started working. As for why'd they need to be configured for me ... :no_good_man: but maybe it helps you narrow it down :smile:

Note that didn't test this explicitly, I just hard coded the DATABASE_URL...

DimitriGilbert avatar Apr 01 '24 09:04 DimitriGilbert

@DimitriGilbert was this in docker?

potts99 avatar Apr 06 '24 14:04 potts99

yes, it was in a docker compose stack

DimitriGilbert avatar Apr 06 '24 15:04 DimitriGilbert

Same issue here. Installed on Dockge (Portainer equivalent). Using standard Docker-compose file.

gmdelisle avatar Sep 07 '24 16:09 gmdelisle