MongoDB Atlas connection problem

prisma

#1

I’m following this this doc and trying to setup a docker container that connects to a database on the MongoDB Atlas (free M0 tier).

the docker-compose.yml looks like:

version: '3'
services:
  prisma:
    image: prismagraphql/prisma:1.27
    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+srv://USERNAME:PASSWORD@tmcluster-wvpvr.mongodb.net/mydb?retryWrites=true'

It seems prisma is not running on http://localhost:4466/ after the command docker-compose up -d was executed. And if I run the command prisma deploy I will get an error including these messages:

  environment FetchError: request to http://localhost:4466/management failed,     reason: socket hang up
  environment     at ClientRequest.<anonymous> (/Users/username/.config/yarn/global/node_modules/cross-fetch/node_modules/node-fetch/lib/index.js:1393:11)
  environment     at ClientRequest.emit (events.js:197:13)
  environment     at ClientRequest.EventEmitter.emit (domain.js:446:20)
  environment     at Socket.socketOnEnd (_http_client.js:431:9)
  environment     at Socket.emit (events.js:202:15)
  environment     at Socket.EventEmitter.emit (domain.js:464:23)
  environment     at endReadableNT (_stream_readable.js:1129:12)
  environment     at processTicksAndRejections (internal/process/next_tick.js:76:17) +11ms
Error: Could not connect to server at http://localhost:4466. Please check if your server is running.
    at Deploy.<anonymous> (/Users/username/.config/yarn/global/node_modules/prisma-cli-core/src/commands/deploy/deploy.ts:127:13)
    at step (/Users/username/.config/yarn/global/node_modules/prisma-cli-core/dist/commands/deploy/deploy.js:45:23)
    at Object.next (/Users/username/.config/yarn/global/node_modules/prisma-cli-core/dist/commands/deploy/deploy.js:26:53)
    at fulfilled (/Users/username/.config/yarn/global/node_modules/prisma-cli-core/dist/commands/deploy/deploy.js:17:58)
    at processTicksAndRejections (internal/process/next_tick.js:81:5)

I’ve tried by removing “+srv” part from the uri and recreate container, this time the prisma seems running but prisma deploy would end up with these error messages:

 Creating stage default for service default...  client Sending query to cluster local +57s
  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        +0ms
  client { name: 'default', stage: 'default', secrets: null } +1ms
 !
FetchError: request to http://localhost:4466/management failed, reason: socket hang up
    at ClientRequest.<anonymous> (/Users/username/.config/yarn/global/node_modules/cross-fetch/node_modules/node-fetch/lib/index.js:1393:11)
    at ClientRequest.emit (events.js:197:13)
    at ClientRequest.EventEmitter.emit (domain.js:446:20)
    at Socket.socketOnEnd (_http_client.js:431:9)
    at Socket.emit (events.js:202:15)
    at Socket.EventEmitter.emit (domain.js:464:23)
    at endReadableNT (_stream_readable.js:1129:12)
    at processTicksAndRejections (internal/process/next_tick.js:76:17)

The results are similar to above if I replace the uri with another one like mongodb+srv://USERNAME:PASSWORD@tmcluster-wvpvr.mongodb.net/admin or others that are supposed for older versions of MongoDB.


#2

Hi @miptrel

You will require to use the endpoint with admin db access.

it will look something like this:

mongodb+srv://USERNAME:PASSWORD@tmcluster-wvpvr.mongodb.net/admin

#3

Downgrade to prisma docker image

prisma:
    image: prismagraphql/prisma:1.26.5

#4

Thanks! It’s now works after both @pantharshit00 and @jorge’s solutions were applied.

(It seems I need to downgrade to make the correct uri working)


#5

This worked for me as well after struggling with it for hours and trying a bunch of other suggestions. How do we report this bug in prismagraphql/prisma:1.28?


#6

not sure… I reported it on slack and they said they were going to look into it


#7

Thanks for reporting this. I can reproduce the problem and we have identified the cause. We’ll release a fix on Monday.


#8

The issue should now be fixed in 1.28.3. Please let me know if you’re still having problems.


#9

Hi,

I’m using version 1.30 and looks like it still remains this issue :frowning:


#10

@janiele2109

Can you please provide me your docker-compose file?