Cannot access mongodb through browser - It looks like you are trying to access MongoDB over HTTP on the native driver port

前端 未结 5 1880
我在风中等你
我在风中等你 2021-01-30 11:09

I open terminal and enter the following commands

sudo mongod

which then outputs

[initandlisten] waiting for connections on port         


        
相关标签:
5条回答
  • 2021-01-30 11:46

    HTTP interface for MongoDB Deprecated since version 3.2 :)

    Check Mongo Docs: HTTP Status Interface

    0 讨论(0)
  • 2021-01-30 11:50

    Like the previous comment mention, the message "It looks like you are trying to access MongoDB over HTTP on the native driver port." its a warning because you are missunderstanding this line: mongoose.connect('mongodb://localhost/info'); and browsing this url: http://localhost:28017/

    However, if you want to see the mongo's admin web page, you could do it, with this command:

    mongod --rest --httpinterface

    browsing this url: http://localhost:28017/

    the parameter httpinterface activate the admin web page, and the parameter rest its needed for activate the rest services the page require

    0 讨论(0)
  • 2021-01-30 11:51

    MongoDB has a simple web based administrative port at 28017 by default.

    There is no HTTP access at the default port of 27017 (which is what the error message is trying to suggest). The default port is used for native driver access, not HTTP traffic.

    To access MongoDB, you'll need to use a driver like the MongoDB native driver for NodeJS. You won't "POST" to MongoDB directly (but you might create a RESTful API using express which uses the native drivers). Instead, you'll use a wrapper library that makes accessing MongoDB convenient. You might also consider using Mongoose (which uses the native driver) which adds an ORM-like model for MongoDB in NodeJS.

    If you can't get to the web interface, it may be disabled. Normally, I wouldn't expect that you'd need it for doing development unless you're checking logs and such.

    0 讨论(0)
  • 2021-01-30 11:52

    I am in ubuntu 14.04 and mongod is registered as an upstart service. The answers in this post sent me in the right direction. The only adaptation I had to do to make things work with the upstart service was to edit /etc/mongod.conf. Look for the lines that read:

    # Enable the HTTP interface (Defaults to port 28017).
    # httpinterface = true
    

    Just remove the # in front of httpinterface and restart the mongod service:

    sudo restart mongod
    

    Note: You can also enable the rest interface by adding a line that reads rest=true right below the httpinterface line mentioned above.

    0 讨论(0)
  • 2021-01-30 11:56

    Before Mongo 3.6:

    You may start mongodb with

    mongod --httpinterface
    

    And access it on

    http://localhost:28017
    

    Since version 2.6: MongoDB disables the HTTP interface by default.

    Update

    HTTP Interface and REST API

    MongoDB 3.6 removes the deprecated HTTP interface and REST API to MongoDB.

    See Mongo http interface and rest api

    0 讨论(0)
提交回复
热议问题