No suitable servers found (`serverSelectionTryOnce` set): [connection timeout calling ismaster on '10.0.0.106:27017']

flower picture flower · Mar 21, 2017 · Viewed 9.9k times · Source

i have this issue with laravel project use mongoDB

ConnectionTimeoutException in Collection.php line 192:
No suitable servers found (`serverSelectionTryOnce` set): [connection
timeout calling ismaster on '10.0.0.106:27017']

i did

 service ngnix restart 

but its not work still same i dont know how solve it

Answer

Grave picture Grave · Mar 26, 2017

the reason is mongod server not support ipv6 by default, but the systemOS used ipv6. you can delete the ipv6 on system: remove this line

::1 localhost' from /etc/hosts

or, enable the mongod ipv6 support ! eg:

./bin/mongod --filePermissions 0777 --ipv6