0

I was wondering if someone could help me figure this out.

I have a Node application using a Postgres database with PostGIS running inside a docker container. Whenever Prisma tries to connect to it, I get the error P1001: Can't reach database server at localhost:15432. I can connect to it fine using some database management tools, and I can connect to deployed Postgress database using PostGIS just fine. Below is my docker-compose file and the connection string.

version: '3.8'

services:
  postgres:
    container_name: test-postgres
    image: kartoza/postgis:14-3.3--v2022.08.30
    ports:
      - 15432:5432
    environment:
      - POSTGRES_USER=admin
      - POSTGRES_PASSWORD=secret
      - POSTGRES_DB=test-db
    volumes:
      - postgis-data:/var/lib/postgresql

volumes:
  postgis-data:

DATABASE_URL="postgresql://admin:secret@localhost:15432/test-db?schema=public"

The schema.prisma file:

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["interactiveTransactions"]
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}
JE_2123A
  • 25
  • 5
  • prisma runs in another docker container, or outside docker? – erik258 Sep 27 '22 at 15:11
  • Prisma runs outside of Docker – JE_2123A Sep 27 '22 at 15:32
  • 1
    might be worth testing with `127.0.0.1` instead of `localhost` to take ipv6 and unix domain sockets out of the equation. – erik258 Sep 27 '22 at 16:05
  • Did you test with this exact file and URL? What is the prisma code? – jjanes Sep 27 '22 at 16:06
  • I tried it with 127.0.0.1 instead of localhost, but I still have the same problem. Yes, it's the exact docker compose and URL that I'm attempting this with. I updated the post with the code that exists in the schema.prisma file. – JE_2123A Sep 27 '22 at 16:44
  • Did you try to use the port `5432` instead of `15432`, in your connection string? Or you may need to use `host.docker.internal` as the host instead of `localhost`. See [here](https://stackoverflow.com/a/24326540/9530790) – shmuels Sep 30 '22 at 16:16

0 Answers0