Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
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 =; 

var lastName =; 


firstName: firstName, 

lastName: lastName 


if(err) return next(err); 





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

var schema = new mongoose.Schema({ 

firstName: String, 

lastName: String 


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





2 Answers

0 votes
by (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


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

0 votes
by (108k points)

MongoDB has an uncomplicated web-based central port at 28017 by default. At the default port of 27017, there is no HTTP access. The error port is used for native driver access, not HTTP traffic.


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

by (100 points)
I too am getting this error.  I have a mongo-express container and a mongodb container (and a node.js container).  Everything works on my laptop if I use docker-compose with a mongo.yaml file that starts all 3 apps.  But if I load those containers in an azure app service (using az webapp create, it fails.  I commented out the node.js container, so it's just the two mongo containers, and it just gives me that message (no errors in any logs).  I was just expecting to query  my mongodb container's database using mongo-express.  works on laptop, fails in azure app service.

Related questions

0 votes
2 answers
0 votes
1 answer
0 votes
2 answers
0 votes
2 answers
0 votes
1 answer

Browse Categories