title: Docker Prisma Error P1001: Can't reach database server at `postgres`:`5432`
body: <p>After hours of searchs, I must bow dow and ask you some advices on my problem :</p>
  <p>My backend (express + prisma + postgresql) is Dockerized, functionning BUT I can't use <code>npx prisma</code> commands from my wsl2 zsh terminal.</p>
  <p>Here is my .env</p>
  <pre><code># Database settings
  NODE_ENV=dev
  DB_USER=user
  DB_PASS=password
  DATABASE_URL=&quot;postgresql://${DB_USER}:${DB_PASS}@postgres/chimere?schema=public&quot;
  </code></pre>
  <p>Dockerfile :</p>
  <pre><code>FROM node:17-alpine3.14 as base
  
  WORKDIR /user/src/app
  COPY package*.json /user/src/app/
  EXPOSE 5000
  
  FROM base as dev
  ENV NODE_ENV=development
  RUN npm install -g nodemon &amp;&amp; npm install
  COPY . /user/src/app/
  RUN npx prisma generate
  CMD [&quot;nodemon&quot;, &quot;src/index.js&quot;]
  
  FROM base as production
  ENV NODE_ENV=production
  RUN npm ci
  COPY . /user/src/app/
  RUN npx prisma generate
  CMD [&quot;node&quot;, &quot;src/index.js&quot;]
  </code></pre>
  <p>docker-compose.yml :</p>
  <pre><code>version: '3.8'
  services:
    postgres:
      image: postgres
      restart: always
      environment:
        - POSTGRES_USER=${DB_USER}
        - POSTGRES_PASSWORD=${DB_PASS}
      volumes:
        - postgres:/var/lib/postgresql/data
      ports:
        - '5432:5432'
    web:
        build:
          context: ./
          target: dev
        restart: always
        volumes:
          - .:/usr/src/app
          - uploaded-files:/usr/src/app/public/media/files
          - uploaded-pictures:/usr/src/app/public/media/pictures
        command: npm run start:dev
        ports:
          - &quot;5000:5000&quot;
        environment:
          NODE_ENV: development
          DEBUG: nodejs-docker-express:*
  
  volumes:
      postgres:
      uploaded-files:
      uploaded-pictures:
  </code></pre>
  <p>and Prisma Schema :</p>
  <pre><code>generator client {
      provider      = &quot;prisma-client-js&quot;
      binaryTargets = [&quot;native&quot;, &quot;linux-musl&quot;]
  }
  
  datasource db {
      provider = &quot;postgresql&quot;
      url      = env(&quot;DATABASE_URL&quot;)
  }
  </code></pre>
  <p>Like you can see I'm prettry new to Docker and almost everything is an adjusted copypasta from Google (:</p>
  <p>How can I get my app to work AND get my commands to work aswell ?</p>
  <p>Thanks !</p>