MongoConnectionException-无法连接到:localhost:27017 [英] MongoConnectionException - Failed to connect to: localhost:27017

查看:80
本文介绍了MongoConnectionException-无法连接到:localhost:27017的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下PHP代码连接到MongoDB:

I used the following PHP code to connect to MongoDB:

$m = new MongoClient("mongodb://localhost:27017");

但是,出现以下错误:

致命错误:未捕获的异常"MongoConnectionException",消息为无法连接至:localhost:27017:未知错误"

Fatal error: Uncaught exception 'MongoConnectionException' with message 'Failed to connect to: localhost:27017: Unknown error'

我尝试了很多在各种博客中发布的连接字符串的可能性;没有任何帮助.有人有什么想法吗?

I tried lot of connection string possibilities that are posted in various blogs; nothing helps. Does anyone have any ideas?

推荐答案

如果有人遇到此问题,请首先参考以下链接.

If anybody has this issue, refer the following links first.

连接字符串URI格式

PHP MongoClient

在我的情况下,McAfee防火墙导致此问题.当我关闭"防火墙时,它开始工作..

In my case McAfee firewall leads to this problem. When i 'Turn-Off' firewall it started working..

这篇关于MongoConnectionException-无法连接到:localhost:27017的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆