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