Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No suitable servers found #1677

Closed
ChristianBundgaard opened this issue Dec 11, 2018 · 8 comments
Closed

No suitable servers found #1677

ChristianBundgaard opened this issue Dec 11, 2018 · 8 comments
Labels

Comments

@ChristianBundgaard
Copy link

When I run the ConnectionTest, it succesfully connects to the database (and I can connect in Robo 3T as well), but one of the tests fails and gives me this. The same error message appears when I try to run "artisan migrate".

1) Tests\Unit\MongoConnectionTest::testQueryLog MongoDB\Driver\Exception\ConnectionTimeoutException: No suitable servers found ('serverSelectionTryOnce' set): [connection refused calling ismaster on 'localhost:27017']

I am using a fresh installation of Laravel, and the only things I have done is following your guide. If it matters, I am using Docker and Vessel.

I thought it would be a connection issue, but since I can connect, it doesn't make much sense to me. I have read similar, older threads with the same error, but I can't find a solution.

@Smolevich
Copy link
Contributor

Descibe this moment, please.

  1. What command do you run?
  2. Docker and Docker-compose?

@ChristianBundgaard
Copy link
Author

  1. Just ran 'php test' in the example, but same error comes when trying to run 'php artisan migrate' ex.
  2. Docker-compose below.

version: '2' services: app: build: context: ./docker/app dockerfile: Dockerfile image: vessel/app ports: - "${APP_PORT}:80" environment: CONTAINER_ENV: "${APP_ENV}" XDEBUG_HOST: "${XDEBUG_HOST}" WWWUSER: "${WWWUSER}" volumes: - .:/var/www/html networks: - vessel node: build: context: ./docker/node dockerfile: Dockerfile args: uid: "${WWWUSER}" image: vessel/node user: node volumes: - .:/var/www/html networks: - vessel mongo: image: mongo restart: always environment: MONGO_INITDB_ROOT_USERNAME: "${DB_USERNAME}" MONGO_INITDB_ROOT_PASSWORD: "${DB_PASSWORD}" ports: - 27017:27017 networks: - vessel redis: image: redis:alpine volumes: - vesselredis:/data networks: - vessel networks: vessel: driver: "bridge" volumes: vesselredis: driver: "local"

@Smolevich
Copy link
Contributor

  1. Ping in container app host mongo
  2. Value of DB_HOST must be mongo if ping was successful

@ahren-condos-ca
Copy link

ahren-condos-ca commented Mar 30, 2019

Im getting the same... was working fine until I created about 700K Jobs to do inserts that I ran on 10 workers... after about 400K ... then DB hung... now even after a docker-compose down & up -d... container stays up but get the error message
MongoDB/Driver/Exception/ConnectionTimeoutException with message 'No suitable servers found ('serverSelectionTryOnce' set): [connection refused calling ismaster on 'mongodb:27017']'

Any resolution?

@Messhias
Copy link

Im getting the same... was working fine until I created about 700K Jobs to do inserts that I ran on 10 workers... after about 400K ... then DB hung... now even after a docker-compose down & up -d... container stays up but get the error message
MongoDB/Driver/Exception/ConnectionTimeoutException with message 'No suitable servers found ('serverSelectionTryOnce' set): [connection refused calling ismaster on 'mongodb:27017']'

Any resolution?

I'm facing the same problems, and sometimes even the connection stops to work, this library if MongoDB is so unstable, we're starting considered to move to Redis or another NoSQL database, MongoDB in future it'll be no more supported for php anyway.

@ahren-condos-ca
Copy link

ahren-condos-ca commented Apr 22, 2019

I ended up wiping that DB and restoring from a backup. I never figured out of my DB got corrupted or if there were just too many write operations queued up that were taking forever making mongo pretty much unresponsive. I agree that lack of support and good tools for mongo admin make it a less desirable choice. We're considering moving to mysql and leveraging their newer JSON support for our unstructured data requirements.

@Messhias
Copy link

Im getting the same... was working fine until I created about 700K Jobs to do inserts that I ran on 10 workers... after about 400K ... then DB hung... now even after a docker-compose down & up -d... container stays up but get the error message
MongoDB/Driver/Exception/ConnectionTimeoutException with message 'No suitable servers found ('serverSelectionTryOnce' set): [connection refused calling ismaster on 'mongodb:27017']'
Any resolution?

I'm facing the same problems, and sometimes even the connection stops to work, this library if MongoDB is so unstable, we're starting considered to move to Redis or another NoSQL database, MongoDB in future it'll be no more supported for php anyway.

So, in the end, we're starting doing this process, MongoDB it was already not so good database (at least I have horribles experiences with it using C++, Python and now in PHP), we'll move everything to Redis and we give up of mongo and this library also, and probably after 2 years it'll be deprecated of PHP for sure and our project was made to have stability and we don't want to use things that made it more unstable.

Thank you guys and good luck.

@maneeshms
Copy link

maneeshms commented Aug 30, 2020

Hi I am getting this error
image
I had tried

'mongodb' => [
               'driver'   => 'mongodb+srv',
               'host'     => [
                   'mongoUser:mongoPass@cluster1.xxxx.mongodb.net:27017/payment?retryWrites=true&w=majority',
               ],
               'port'     => 27017,
               'database' => env('DB_DATABASE'),
               'username' => env('DB_USERNAME'),
               'password' => env('DB_PASSWORD'),
               'options'  => [
                   'ssl'        => true,
                   'replicaSet' => 'replicaSetName',
               ],
           ],

and

Also I tried dsn in it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants