I am trying to connect MongoDB Server remotely from localhost but unable to connect. I did like below inside my code:
public function connect() {
require_once 'dbcon/config.php';
$dbname='koolfeedback';
$con=new MongoClient('mongodb://10.25.*.*:27017');
$connect=$con->$dbname;
$this->db=$connect;
return $connect;
}
I am running my project inside localhost (Xampp). When I was using mongodb locally it was connecting well but now I need to connect to remote server and unable to do that.
On the remote mongo server you have to bind your IP or set it 0.0.0.0 . Mongo only listens to localhost by default.