1

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.

3
  • What is the error saying? Commented May 6, 2016 at 13:07
  • page is not coming at all.and this error localhost is currently unable to handle this request. HTTP ERROR 500 is coming. Commented May 6, 2016 at 13:25
  • well, check the logs, something must have stored PHP's error Commented May 6, 2016 at 17:42

1 Answer 1

0

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.

Sign up to request clarification or add additional context in comments.

2 Comments

:check my post.I have already mentioned there the ip still there issue.
@ anwerjunaid : i have tried also as per you still issue there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.