MongoConnectionException - Failed to connect to: localhost:27017 [closed]

蓝咒 提交于 2019-12-22 09:27:28

问题


I used the following PHP code to connect to MongoDB:

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

However, I am getting the following error:

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?


回答1:


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

Connection String URI Format

PHP MongoClient

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



来源:https://stackoverflow.com/questions/14215833/mongoconnectionexception-failed-to-connect-to-localhost27017

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!