Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connecting to mongodb through the browser?

Tags:

Im reading the mongodb guide, but I dont get this:

mongodb://fred:foobar@localhost

It says I can connect to the mongodb through web browser.

I have tried this, but it doesn't work. Safari/Firefox can't recognize the mongodb protocol.

And why should I do it?

Isn't the mongodb server just for connecting through the command line?

And what is the difference between port 27017 and 28017?

Should I connect through http or mongodb protocol?

like image 353
never_had_a_name Avatar asked Aug 29 '10 15:08

never_had_a_name


People also ask

What is MongoDB localhost URL?

Without any arguments, the mongo command attempts to connect to a local MongoDB instance. To do this, it attempts to connect to port 27017 on the local loopback address: 127.0. 0.1:27017 .

How do I access the HTTP interface of MongoDB?

To access the http interface an administrator may, for example, point a browser to http://localhost:28017 if mongod is running with the default port on the local machine.


2 Answers

When you start mongod (the MongoDB daemon), it starts listening on two ports by default.

  1. 27017: the default port accessed by the various MongoDB drivers.
  2. 28017: a port that handles HTTP requests and provides some general monitoring.

What you've listed mongodb://fred:foobar@localhost actually represents this: mongodb://fred:foobar@localhost:27017 and this is the access protocol for MongoDB drivers.

The other "thing" you're seeing is port 28017. This is (by default) simply an overview of what's happening with the mongod instance on that server. Requests made from a web browser to this port will show an HTML output of the server overview.

If you start mongod with a different port number (i.e.: 7777), the "monitor" port will always be 1000 higher (i.e.: 8777).

If you want some advanced features like the ability to query via the web browser, you can start mongod with the --rest switch. You will then be able to run certain queries with a simple http get requestlink text (http://localhost:8777/mydb/mycollection/?filter_a=1).

If you're using language-specific MongoDB drivers (like most people will). Then you'll find that you'll have "connection strings" of the form mongodb://user:pwd@host:port/. These are similar in purpose to the usual connection strings you're used to for other Database products.

like image 134
Gates VP Avatar answered Nov 04 '22 08:11

Gates VP


Increment by one thousand (28017), and use HTTP, not mongodb.

Note that this will "connect" you to the mongodb process, but it's not like phpMyAdmin or anything.

like image 26
Josh K Avatar answered Nov 04 '22 09:11

Josh K