Prisma1: prisma deploy yields to "request to http://localhost:4466/management failed, reason: socket hang up"

Created on 16 Jan 2019  Â·  7Comments  Â·  Source: prisma/prisma1

Describe the bug
Following the tutorial of doc 1.24 on setting up prisma with an existing mongodb on ubuntu 16.04

To Reproduce
Steps to reproduce the behavior:

  1. prisma init prisma
  2. enter mongodb connection string with admin credentials
  3. select existing database and enter name
  4. cd prisma & docker-compose up -d
  5. prisma deploy

Expected behavior
Expected to run successfully

Versions (please complete the following information):

  • Connector: MongoDB
  • Prisma Server: 1.24.0
  • prisma CLI: [[email protected] node-v11.6.0]
  • OS: [Ubuntu 16.04]

prisma deploy debug log:

config CWD /home/prismaUser/prisma +0ms
config HOME /home/prismaUser +3ms
config definitionDir /home/prismaUser/prisma +0ms
config definitionPath /home/prismaUser/prisma/prisma.yml +0ms
cli { isGlobal: true } +0ms
StatusChecker setting status checker +0ms
cli command id deploy +6ms
cli:plugincache Got plugin from cache +0ms
cli:plugincache /home/prismaUser/.cache/prisma/plugins.json +0ms
cli:plugincache Got plugin from cache +2ms
cli:plugincache /home/prismaUser/.cache/prisma/plugins.json +0ms
plugins findCommand prisma-cli-core +0ms
plugin requiring command +0ms
cli-engine:plugins:manager requiring /home/prismaUser/.nvm/versions/node/v11.6.0/lib/node_modules/prisma/node_modules/prisma-cli-core +0ms
cli-engine:plugins:manager required +1s
plugin required command +1s
StatusChecker setting status checker +1s
prisma definition making cluster here +0ms
client Initializing cluster client +0ms
deploy checking if project exists +0ms
client Sending query to cluster local +6ms
client http://localhost:4466/management +1ms
client
client       query($name: String! $stage: String!) {
client         project(name: $name stage: $stage) {
client           name
client           stage
client         }
client       }
client      +0ms
client { name: 'default', stage: 'default' } +1ms
deploy adding project +17s

Creating stage default for service default...  client Sending query to cluster local +17s
  client http://localhost:4466/management +0ms
  client       mutation addProject($name: String! $stage: String! $secrets: [String!]) {
  client         addProject(input: {
  client           name: $name,
  client           stage: $stage
  client           secrets: $secrets
  client         }) {
  client           project {
  client             name
  client           }
  client         }
  client       }
  client        +1ms
  client { name: 'default', stage: 'default', secrets: null } +0ms
 !
FetchError: request to http://localhost:4466/management failed, reason: read ECONNRESET
    at ClientRequest.<anonymous> (/home/prismaUser/.nvm/versions/node/v11.6.0/lib/node_modules/prisma/node_modules/node-fetch/lib/index.js:1393:11)
    at ClientRequest.emit (events.js:188:13)
    at ClientRequest.EventEmitter.emit (domain.js:441:20)
    at Socket.socketErrorListener (_http_client.js:399:9)
    at Socket.emit (events.js:188:13)
    at Socket.EventEmitter.emit (domain.js:441:20)
    at emitErrorNT (internal/streams/destroy.js:82:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
    at process.internalTickCallback (internal/process/next_tick.js:72:19)
  util timed out +0ms
Exiting with code: 0

docker-compose.yml

version: '3'
services:
  prisma:
    image: prismagraphql/prisma:1.24
    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: mongo
            database: myDB
            uri: 'mongodb://admin:[email protected]:27017/admin'

docker ps

CONTAINER ID        IMAGE                       COMMAND                  CREATED             STATUS              PORTS                    NAMES
9104e6b30ae0        prismagraphql/prisma:1.24   "/bin/sh -c /app/sta…"   27 minutes ago      Up 32 seconds       0.0.0.0:4466->4466/tcp   prisma_prisma_1

It successfully extracted the schema from myDB when I run prisma init and created a correct datamodel file.
Do you have a way to debug this further?

kinquestion areserver

Most helpful comment

Yup, that did it.
Thanks a lot!

All 7 comments

Hi,

Looks like your prisma server is constantly crashing as I can see from the output of docker ps. It is a connection issue to your database

The reason is 127.0.0.1 does not point to your local machine inside docker. You should use host.docker.internal to point to the local machine. The following URI should work: mongodb://admin:[email protected]:27017/admin

I tried doing docker-compose down, modified docker-compose.yml as you said but it doesn't seem to have changed anything...
Here's my new docker-compose

version: '3'
services:
  prisma:
    image: prismagraphql/prisma:1.24
    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: mongo
            database: myDB
            uri: 'mongodb://admin:[email protected]:27017/admin'

output of docker ps

CONTAINER ID        IMAGE                       COMMAND                  CREATED             STATUS              PORTS                    NAMES
5a6c653980db        prismagraphql/prisma:1.24   "/bin/sh -c /app/sta…"   6 minutes ago       Up 1 second         0.0.0.0:4466->4466/tcp   prisma_prisma_1

and docker-compose logs

prisma_1  | {"@timestamp":"2019-01-16T15:02:43.354+00:00","@version":1,"message":"Exception in monitor thread while connecting to server host.docker.internal:27017","logger_name":"org.mongodb.driver.cluster","thread_name":"cluster-ClusterId{value='5c3f4791e03dd80007f4b554', description='null'}-host.docker.internal:27017","level":"INFO","level_value":20000,"stack_trace":"com.mongodb.MongoSocketException: host.docker.internal\n\tat com.mongodb.ServerAddress.getSocketAddress(ServerAddress.java:188)\n\tat com.mongodb.internal.connection.AsynchronousSocketChannelStream.openAsync(AsynchronousSocketChannelStream.java:86)\n\tat com.mongodb.internal.connection.AsynchronousSocketChannelStream.open(AsynchronousSocketChannelStream.java:67)\n\tat com.mongodb.internal.connection.InternalStreamConnection.open(InternalStreamConnection.java:126)\n\tat com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:117)\n\tat java.lang.Thread.run(Thread.java:748)\nCaused by: java.net.UnknownHostException: host.docker.internal\n\tat java.net.InetAddress.getAllByName0(InetAddress.java:1281)\n\tat java.net.InetAddress.getAllByName(InetAddress.java:1193)\n\tat java.net.InetAddress.getAllByName(InetAddress.java:1127)\n\tat java.net.InetAddress.getByName(InetAddress.java:1077)\n\tat com.mongodb.ServerAddress.getSocketAddress(ServerAddress.java:186)\n\t... 5 common frames omitted\n","HOSTNAME":"5a6c653980db"}
prisma_1  | Server running on :4466

Are you using Linux? If so, host.docker.internal will not work for you, unfortunately: https://github.com/docker/for-linux/issues/264

You can use https://stackoverflow.com/a/49149020/7152576 as a workaround or spin up a MongoDB instance inside of docker.

If you need further help setting this up, contact me on slack: slack.prisma.io ,that way I can have a chat and help you debug the issue

Thanks for your help.
Yes I'm on Linux. I've tried using dockerhost as recommended the stackoverflow post you linked but I get the same result.
I've sent you a message on slack.
Here's my new docker-compose.yml file

version: '3'
services:
  # Need this on linux to be able to access the host from the container (connection string)
  dockerhost:
    image: qoomon/docker-host
    cap_add:
      - NET_ADMIN
      - NET_RAW
    restart: on-failure
  prisma:
    depends_on:
      - dockerhost
    image: prismagraphql/prisma:1.24
    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: mongo
            database: myDB
            uri: 'mongodb://admin:supersecret@dockerhost:27017/admin'

I guess dockerhost is broken somehow. I tested out some workarounds a Linux machine and you can use host networking for the time being till docker supports host.docker.internal for Linux. Host network will allow you to use localhost with docker that will point to your own machine

version: '3'
services:
  prisma:
    image: prismagraphql/prisma:1.24
    restart: always
    network_mode: host
    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: mongo
            uri: 'mongodb://localhost:27017/admin'

Yup, that did it.
Thanks a lot!

I guess dockerhost is broken somehow. I tested out some workarounds a Linux machine and you can use host networking for the time being till docker supports host.docker.internal for Linux. Host network will allow you to use localhost with docker that will point to your own machine

version: '3'
services:
  prisma:
    image: prismagraphql/prisma:1.24
    restart: always
    network_mode: host
    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: mongo
            uri: 'mongodb://localhost:27017/admin'

When i added network_mode: host, it worked for me also. Thanks a lot for saving my hours.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MitkoTschimev picture MitkoTschimev  Â·  3Comments

sorenbs picture sorenbs  Â·  3Comments

AlessandroAnnini picture AlessandroAnnini  Â·  3Comments

marktani picture marktani  Â·  3Comments

ragnorc picture ragnorc  Â·  3Comments