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.
Descibe this moment, please.
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"
app host mongoDB_HOST must be mongo if ping was successfulIm 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?
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.
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.
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.
Hi I am getting this error

I had tried
'mongodb' => [
'driver' => 'mongodb+srv',
'host' => [
'mongoUser:[email protected]: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
Most helpful comment
apphostmongoDB_HOSTmust bemongoif ping was successful