laravel 找不到合适的服务器(`serverSelectionTryOnce` 集):[连接超时调用 ismaster on '10.0.0.106:27017']

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42927202/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 15:37:42  来源:igfitidea点击:

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

phpmongodblaravellaravel-5php-mongodb

提问by flower

i have this issue with laravel project use mongoDB

我有这个问题,laravel 项目使用 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

但它不起作用还是一样我不知道如何解决它

回答by Grave

the reason is mongodserver not support ipv6 by default, but the systemOSused ipv6. you can delete the ipv6 on system: remove this line

原因是mongod服务器默认不支持ipv6,而是systemOS使用ipv6。您可以删除系统上的 ipv6:删除此行

::1 localhost' from /etc/hosts

or, enable the mongod ipv6 support ! eg:

或者,启用 mongod ipv6 支持!例如:

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

回答by STIKO

I had this issue when I changed php version. The solution for me was to add mongo extension to php.ini file of the new php version. My php.ini on mac

我在更改 php 版本时遇到了这个问题。我的解决方案是将 mongo 扩展名添加到新 php 版本的 php.ini 文件中。我在 mac 上的 php.ini

/usr/local/etc/php/7.1/php.ini

Just add

只需添加

;extension=mongodb.so

回答by Codex

Reason for this is there are too many open connection requests to database. Please check if u have any ajax calls running in ur application. you can login to cloudmongo where you have hosted the database cluster and see the number of collections going beyond 100.You might be having too many dbs in the same cluster. I suggest you move few dbs to another cluster.

原因是对数据库的打开连接请求太多。请检查您的应用程序中是否有任何 ajax 调用正在运行。您可以登录到您托管数据库集群的 cloudmongo,并看到集合数量超过 100。您可能在同一集群中拥有太多 dbs。我建议您将几个 dbs 移动到另一个集群。

Hope it helps.

希望能帮助到你。