It looks like you are trying to access mongodb over http on the native driver port. docker

I open terminal and enter the following commands

sudo mongod

which then outputs

[initandlisten] waiting for connections on port 27017

I open another terminal and enter

sudo mongo

which open the mongo shell and prompts for mongo commands, but when I go to localhost/27017 I receive the following message:

It looks like you are trying to access MongoDB over HTTP on the native driver port.

I created a simple nodejs application using express and when I POST data it seems the mongodb gets hung up. This is the message which I receive in the terminal in which I start my express application and the page never posts the data. So I believe the problem lies within mongo but I cannot figure it out.

POST /info 200 120002ms

Here is my express code

var Info = require('../models/info');
var path = require('path');
var fs = require('fs');
var join = path.join;

exports.form = function(req,res){

    res.render('info', {
        myName: 'Michael'
    });
};

exports.submit = function(){
console.log('Within exports.submit 1');
    return function(req,res,next){
        console.log('Within exports.submit 2 ');
        var firstName = req.name.first;
        var lastName = req.name.last;
        Info.create({
            firstName: firstName,
            lastName: lastName
        },function(err){
            if(err) return next(err);

            res.redirect('/')
        });
    }
};

Model

var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/info');

var schema = new mongoose.Schema({
    firstName: String,
    lastName: String
});

module.exports = mongoose.model('info',schema);

app.js

...
app.get('/info',info.form);
app.post('/info',info.submit);
...

I was building a Meteor package and created a simple helper app (Meteor version 1.6.1.4) to run the package with while developing.

Suddenly I get this on the browser after a rebuild (approx. 500th rebuild in a row)

It looks like you are trying to access MongoDB over HTTP on the native driver port.

And that's it. No errors in the console, browser & meteor tool.

I have MONGO_URL set in my env vars, so I wasn't using the bundled MongoDB.

Killing and restarting meteor solved the issue, but I thought I'd bring this up just in case.

asked Oct 16, 2019 in Web Technology by (47.6k points)

I open the terminal and enter the following commands

sudo mongod

which then outputs

[initandlisten] waiting for connections on port 27017

I open another terminal and enter

sudo mongo

which open the mongo shell and prompts for mongo commands, but when I go to localhost/27017 I receive the following message:

It looks like you are trying to access MongoDB over HTTP on the native driver port.

I created a simple nodejs application using express and when I POST data it seems the mongodb gets hung up. This is the message which I receive in the terminal in which I start my express application and the page never posts the data. So I believe the problem lies within mongo but I cannot figure it out.

POST /info 200 120002ms

Here is my express code

var Info = require('../models/info'); 

var path = require('path'); 

var fs = require('fs'); 

var join = path.join; 

exports.form = function(req,res){ 

res.render('info', { 

myName: 'Michael' 

}); 

}; 

exports.submit = function(){ 

console.log('Within exports.submit 1'); 

return function(req,res,next){ 

console.log('Within exports.submit 2 '); 

var firstName = req.name.first; 

var lastName = req.name.last; 

Info.create({ 

firstName: firstName, 

lastName: lastName 

},function(err){ 

if(err) return next(err); 

res.redirect('/') 

}); 

};

Model

var mongoose = require('mongoose'); mongoose.connect('mongodb://localhost/info'); 

var schema = new mongoose.Schema({ 

firstName: String, 

lastName: String 

}); 

module.exports = mongoose.model('info',schema);

app.js

... 

app.get('/info',info.form); 

app.post('/info',info.submit); 

...

2 Answers

answered Oct 17, 2019 by Vishal (106k points)

To access mongodb through a browser you should use the below-mentioned command:-

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.

How do I access MongoDB HTTP?

HTTP Console MongoDB provides a simple http interface listing information of interest to administrators. This interface may be accessed at the port with numeric value 1000 more than the configured mongod port. The default port for the http interface is 28017.

Why is my MongoDB not connecting?

Ensure Your MongoDB Instance is Running Compass must connect to a running MongoDB instance. Make sure you have installed MongoDB and have a running mongod process. You should also check that the port where your MongoDB instance is running matches the port you provide in the Compass connect dialog.

What is MongoDB localhost URL?

connect('mongodb://localhost:27017/myapp'); This is the minimum needed to connect the myapp database running locally on the default port (27017). If connecting fails on your machine, try using 127.0. 0.1 instead of localhost .

Does MongoDB have a web interface?

MongoDB web interface is a tool used to administrate our database server via the web browser, there are multiple web interface tools available in MongoDB. There is multiple features of the web interface in MongoDB like we can create database and collection by using the web interface.