[英]Can't connect to host mongodb from homestead
I have a laravel 5.2 project on homestead 7 which works with mysql and mongodb, I have configured it to connect to host (my mac AMPPS) mysql and mongodb servers. 我在宅基地7上有一个laravel 5.2项目,可与mysql和mongodb一起使用,我已将其配置为连接到主机(我的mac AMPPS)mysql和mongodb服务器。
mysql is connected successfully but I can't connect to host mongodb from homestead. mysql已成功连接,但无法从宅基连接到主机mongodb。
when I try to connect to host mongodb server from homestead using mongo command I get below error : 当我尝试使用mongo命令从宅基连接到主机mongodb服务器时,出现以下错误:
vagrant@homestead:~$ mongo 192.168.10.1:27017/admin
MongoDB shell version: 3.2.18
connecting to: 192.168.10.1:27017/admin
2018-01-29T13:18:36.967+0000 W NETWORK [thread1] Failed to connect to 192.168.10.1:27017, in(checking socket for error after poll), reason: errno:111 Connection refused
2018-01-29T13:18:36.968+0000 E QUERY [thread1] Error: couldn't connect to server 192.168.10.1:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:231:14
@(connect):1:6
exception: connect failed
as you can see my host ip address is 192.168.10.1
and homestead ip address is 192.168.10.10
. 如您所见,我的主机IP地址是
192.168.10.1
而宅基地IP地址是192.168.10.10
。
And whenever I try to connect to mongodb from laravel mongodb driver I get below error message : 每当我尝试从laravel mongodb驱动程序连接到mongodb时,我都会收到以下错误消息:
ConnectionTimeoutException in Collection.php line 174:
No suitable servers found (`serverSelectionTryOnce` set): [connection refused calling ismaster on '192.168.10.1:27017']
FYI : I used This shell script to install mongodb and it's driver on homestead 7 with php 7.1 仅供参考:我使用此 shell脚本在php 7.1的Homestead 7上安装mongodb及其驱动程序
Any suggestion how to fix this ? 任何建议如何解决这个问题?
The solution to this problem was to edit host /etc/mongodb.conf
and set bind-ip
to 0.0.0.0
解决此问题的方法是编辑主机
/etc/mongodb.conf
并将bind-ip
设置为0.0.0.0
bind_ip = 0.0.0.0
remember to restart mongodb server, then I connected to the host mongodb server. 记得重启mongodb服务器,然后我连接到主机mongodb服务器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.