Could not connect to server at http://localhost:4466


#1

I’m just trying out prisma for the first time. I have a docker instance with Postgres, I am able to connect to the database using pgAdmin.

I started the prisma docker container and it’s running but when I try to run prisma deploy I see the following error:

Could not connect to server at http://localhost:4466. Please check if your server is running.

Here’s my prisma.yml file:

endpoint: http://localhost:4466
datamodel: datamodel.graphql

The docker-compose.yml file:

version: "3"
services:
  prisma:
    image: prismagraphql/prisma:1.25
    restart: always
    ports:
      - "4466:4466"
    environment:
      PRISMA_CONFIG: |
        port: 4466
        # uncomment the next line and provide the env var PRISMA_MANAGEMENT_API_SECRET=my-secret to activate cluster security
        # managementApiSecret: my-secret
        databases:
          default:
            connector: postgres
            host: localhost
            database: graphql-course
            user: postgres
            password: mysecretpassword
            rawAccess: true
            port: '5432'
            migrations: true
            ssl: true

And the datamodel.graphql file:

type User {
  id: ID! @unique
  name: String!
}

#2

Hi,

You cannot use localhost inside docker. You need to replace localhost with host.docker.internal to reference your machine(Only works in mac and windows).

version: "3"
services:
  prisma:
    image: prismagraphql/prisma:1.25
    restart: always
    ports:
      - "4466:4466"
    environment:
      PRISMA_CONFIG: |
        port: 4466
        # uncomment the next line and provide the env var PRISMA_MANAGEMENT_API_SECRET=my-secret to activate cluster security
        # managementApiSecret: my-secret
        databases:
          default:
            connector: postgres
            host: host.docker.internal
            database: graphql-course
            user: postgres
            password: mysecretpassword
            rawAccess: true
            port: '5432'
            migrations: true
            ssl: true

If you are a linux user see this for resolution: https://github.com/prisma/prisma/issues/3880#issuecomment-455184259


#3

I still get this error even with host.docker.internal set as my host. Except mine says Could not connect to server at http://prisma:4466. Please check if your server is running.

  services:
    prisma:
      image: prismagraphql/prisma:1.24
      restart: always
      ports:
        - "4466:4466"
      environment:
        PRISMA_CONFIG: |
          port: 4466
          databases:
            default:
              connector: postgres
              host: host.docker.internal
              port: 5432
              user: example
              password: example
              rawAccess: true
              migrations: true
        PRISMA_ENDPOINT: http://prisma:4466
    # DATABASE CONTAINER
    postgres:
      image: postgres
      container_name: postgres_database
      restart: always
      environment:
        POSTGRES_USER: example
        POSTGRES_PASSWORD: example
      volumes:
        - postgres:/var/lib/postgresql/data
  volumes:
    postgres:

#4

I was able to resolve my issue using this repo as an example: https://github.com/viktorstrate/prisma-server-docker


#5

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.