douba7784 2018-01-29 17:33
浏览 126
已采纳

无法从家园连接主机mongodb

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.

mysql is connected successfully but I can't connect to host mongodb from homestead.

when I try to connect to host mongodb server from homestead using mongo command I get below error :

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.

And whenever I try to connect to mongodb from laravel mongodb driver I get below error message :

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

Any suggestion how to fix this ?

  • 写回答

1条回答 默认 最新

  • dpepbjp126917 2018-01-30 09:46
    关注

    The solution to this problem was to edit host /etc/mongodb.conf and set bind-ip to 0.0.0.0

    bind_ip = 0.0.0.0
    

    remember to restart mongodb server, then I connected to the host mongodb server.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。