Troubleshoot mongodb connection failure

Source: Internet
Author: User
Tags install mongodb mongodb server

Troubleshoot mongodb connection failure

Install mongodb, add the administrator root and test Database User rex, and enable user authentication.

Follow the instructions to connect to the mongodb Database: $ mongo = new Mongo ("mongodb: // rex: 123456 @ localhost ");

The Error "NetworkError: 500 Internal Server Error-http: // 192.168.202.132/montest. php" is reported when firebug is enabled"

Here I tried a lot of methods can not solve, it is not clear why the error, can only look at the official documents of php (http://php.net/manual/zh/mongoclient.construct.php)

If the given host cannot be connected, the mongoonexception will be thrown.

So I started to print this exception:

try {     $mongo = new Mongo("mongodb://rex:123456@localhost"); } catch (Exception $e) {     print $e->getMessage();     exit();   } 

The output result is: Failed to connect to: localhost: 27017: Authentication failed on database 'admin' with username 'rex ': auth failed.

At first glance, we can see that rex is a user of the test database, but the Code does connect to the database admin by default. The problem lies here!

Changed to: $ mongo = new Mongo ("mongodb: // rex: 123456 @ localhost/test ");

Solve the problem!



Mongodb cannot be started, and cannot be connected because the target computer is actively rejected.

This is not because mongodb cannot be started. If you haven't started mongodb, you can connect to it and use it. It is definitely not successful.
Run mongod -- dbpath XXXX/data in the bin directory of mongodb to start mongodb, and then connect to mongodb.

An error occurred while connecting Mongodb to the internet server. There is no problem connecting to the LAN server.

Check the bind_ip parameter because the mongoDB server is bound with an intranet IP address, so it cannot be accessed from the Internet.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.