问题
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