I have Xammp installed in my machine, and I have installed MongoDB. I am able to see the MongoDB module installed in phpinfo
, but when I tried to connect MongoDB through a PHP script, it gives me following error:
Fatal Error : Failed to connect to: localhost:27017: No connection could be made because the target machine actively refused it.
Here is my PHP code:
<?php
try{
$connection = new MongoClient();
var_dump($connection);
} catch(Exception $e){
echo "<pre>"; print_r($e); echo "</pre>";
die;
}
?>
PHP Version : 5.4.19
OS : Windows 7, 32 -bit system
Mongo DB Version : 1.4.5