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 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误