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?
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..