MongoNetworkError: connection 0 to localhost:27017 timed out .(didn't understand previous solutions)










2















I'm completely new with this backend thing, this is my code and when i'm trying to connect the mongoose to the database this error is showing.



I've searched thoroughly and found this example [MongoError: connection 0 to localhost:27017 timed out but I didn't understand how to use this in my project.



 MongoNetworkError: connection 0 to localhost:27017 timed out
at Socket.<anonymous>


(C:UsersABCDPicturesFreelancernode_modulesmongodb-
corelibconnectionconnection.js:259:7)

at Object.onceWrapper (events.js:313:30)
at emitNone (events.js:106:13)
at Socket.emit (events.js:208:7)
at Socket._onTimeout (net.js:422:8)
at ontimeout (timers.js:498:11)
at tryOnTimeout (timers.js:323:5)
at Timer.listOnTimeout (timers.js:290:5)
name: 'MongoNetworkError',
errorLabels: [ 'TransientTransactionError' ],
[Symbol(mongoErrorContextSymbol)]:

THIS IS MY CODE

const express = require('express');
const app = express();
const exphbs = require('express-handlebars');
const mongoose = require('mongoose');
//HANDLEBAR MIDDLEWARE
app.engine('handlebars', exphbs(defaultLayout: 'main'));
app.set('view engine', 'handlebars');
//Connect to mongoose
mongoose.connect('mongodb://localhost/freelancer-dev',
useNewUrlParser: true
)
.then(()=>console.log('mongodb connected'))
.catch(err=> console.log(err));

const port = process.env.PORT ||5000;
app.listen(port,()=>
console.log(`listening at port$port`);
);









share|improve this question
























  • it needs investigation on server. mongoose tries to connect to db and times out. something's wrong with mongodb. seems like Windows Firewall blocking connection. go to control panel and find rule regarding mongodb and allow connections to it

    – num8er
    Nov 16 '18 at 7:26












  • I've downloaded MongoDB 4.0.4 msi package on windows 10, and while i was installing it i think i got some error and skipped that part. Do i need to install It from the scratch again?

    – MDIPANJAN
    Nov 16 '18 at 7:34












  • try to install it again. maybe will help

    – num8er
    Nov 16 '18 at 7:39











  • While I'm trying to re install the MongoDB service , i'm getting this prompt as an error. service 'MongoDB server'(mongodb) failed to start verify that you have sufficient privileges to start system services.

    – MDIPANJAN
    Nov 16 '18 at 8:16







  • 1





    Thank you. I re installed the MongoDB and at last got the right thing : [nodemon] restarting due to changes... [nodemon] restarting due to changes... [nodemon] starting node app.js listening at port5000 mongodb connected :p

    – MDIPANJAN
    Nov 16 '18 at 10:40















2















I'm completely new with this backend thing, this is my code and when i'm trying to connect the mongoose to the database this error is showing.



I've searched thoroughly and found this example [MongoError: connection 0 to localhost:27017 timed out but I didn't understand how to use this in my project.



 MongoNetworkError: connection 0 to localhost:27017 timed out
at Socket.<anonymous>


(C:UsersABCDPicturesFreelancernode_modulesmongodb-
corelibconnectionconnection.js:259:7)

at Object.onceWrapper (events.js:313:30)
at emitNone (events.js:106:13)
at Socket.emit (events.js:208:7)
at Socket._onTimeout (net.js:422:8)
at ontimeout (timers.js:498:11)
at tryOnTimeout (timers.js:323:5)
at Timer.listOnTimeout (timers.js:290:5)
name: 'MongoNetworkError',
errorLabels: [ 'TransientTransactionError' ],
[Symbol(mongoErrorContextSymbol)]:

THIS IS MY CODE

const express = require('express');
const app = express();
const exphbs = require('express-handlebars');
const mongoose = require('mongoose');
//HANDLEBAR MIDDLEWARE
app.engine('handlebars', exphbs(defaultLayout: 'main'));
app.set('view engine', 'handlebars');
//Connect to mongoose
mongoose.connect('mongodb://localhost/freelancer-dev',
useNewUrlParser: true
)
.then(()=>console.log('mongodb connected'))
.catch(err=> console.log(err));

const port = process.env.PORT ||5000;
app.listen(port,()=>
console.log(`listening at port$port`);
);









share|improve this question
























  • it needs investigation on server. mongoose tries to connect to db and times out. something's wrong with mongodb. seems like Windows Firewall blocking connection. go to control panel and find rule regarding mongodb and allow connections to it

    – num8er
    Nov 16 '18 at 7:26












  • I've downloaded MongoDB 4.0.4 msi package on windows 10, and while i was installing it i think i got some error and skipped that part. Do i need to install It from the scratch again?

    – MDIPANJAN
    Nov 16 '18 at 7:34












  • try to install it again. maybe will help

    – num8er
    Nov 16 '18 at 7:39











  • While I'm trying to re install the MongoDB service , i'm getting this prompt as an error. service 'MongoDB server'(mongodb) failed to start verify that you have sufficient privileges to start system services.

    – MDIPANJAN
    Nov 16 '18 at 8:16







  • 1





    Thank you. I re installed the MongoDB and at last got the right thing : [nodemon] restarting due to changes... [nodemon] restarting due to changes... [nodemon] starting node app.js listening at port5000 mongodb connected :p

    – MDIPANJAN
    Nov 16 '18 at 10:40













2












2








2








I'm completely new with this backend thing, this is my code and when i'm trying to connect the mongoose to the database this error is showing.



I've searched thoroughly and found this example [MongoError: connection 0 to localhost:27017 timed out but I didn't understand how to use this in my project.



 MongoNetworkError: connection 0 to localhost:27017 timed out
at Socket.<anonymous>


(C:UsersABCDPicturesFreelancernode_modulesmongodb-
corelibconnectionconnection.js:259:7)

at Object.onceWrapper (events.js:313:30)
at emitNone (events.js:106:13)
at Socket.emit (events.js:208:7)
at Socket._onTimeout (net.js:422:8)
at ontimeout (timers.js:498:11)
at tryOnTimeout (timers.js:323:5)
at Timer.listOnTimeout (timers.js:290:5)
name: 'MongoNetworkError',
errorLabels: [ 'TransientTransactionError' ],
[Symbol(mongoErrorContextSymbol)]:

THIS IS MY CODE

const express = require('express');
const app = express();
const exphbs = require('express-handlebars');
const mongoose = require('mongoose');
//HANDLEBAR MIDDLEWARE
app.engine('handlebars', exphbs(defaultLayout: 'main'));
app.set('view engine', 'handlebars');
//Connect to mongoose
mongoose.connect('mongodb://localhost/freelancer-dev',
useNewUrlParser: true
)
.then(()=>console.log('mongodb connected'))
.catch(err=> console.log(err));

const port = process.env.PORT ||5000;
app.listen(port,()=>
console.log(`listening at port$port`);
);









share|improve this question
















I'm completely new with this backend thing, this is my code and when i'm trying to connect the mongoose to the database this error is showing.



I've searched thoroughly and found this example [MongoError: connection 0 to localhost:27017 timed out but I didn't understand how to use this in my project.



 MongoNetworkError: connection 0 to localhost:27017 timed out
at Socket.<anonymous>


(C:UsersABCDPicturesFreelancernode_modulesmongodb-
corelibconnectionconnection.js:259:7)

at Object.onceWrapper (events.js:313:30)
at emitNone (events.js:106:13)
at Socket.emit (events.js:208:7)
at Socket._onTimeout (net.js:422:8)
at ontimeout (timers.js:498:11)
at tryOnTimeout (timers.js:323:5)
at Timer.listOnTimeout (timers.js:290:5)
name: 'MongoNetworkError',
errorLabels: [ 'TransientTransactionError' ],
[Symbol(mongoErrorContextSymbol)]:

THIS IS MY CODE

const express = require('express');
const app = express();
const exphbs = require('express-handlebars');
const mongoose = require('mongoose');
//HANDLEBAR MIDDLEWARE
app.engine('handlebars', exphbs(defaultLayout: 'main'));
app.set('view engine', 'handlebars');
//Connect to mongoose
mongoose.connect('mongodb://localhost/freelancer-dev',
useNewUrlParser: true
)
.then(()=>console.log('mongodb connected'))
.catch(err=> console.log(err));

const port = process.env.PORT ||5000;
app.listen(port,()=>
console.log(`listening at port$port`);
);






javascript node.js database mongodb mongoose






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 16 '18 at 7:23







MDIPANJAN

















asked Nov 16 '18 at 6:53









MDIPANJANMDIPANJAN

217




217












  • it needs investigation on server. mongoose tries to connect to db and times out. something's wrong with mongodb. seems like Windows Firewall blocking connection. go to control panel and find rule regarding mongodb and allow connections to it

    – num8er
    Nov 16 '18 at 7:26












  • I've downloaded MongoDB 4.0.4 msi package on windows 10, and while i was installing it i think i got some error and skipped that part. Do i need to install It from the scratch again?

    – MDIPANJAN
    Nov 16 '18 at 7:34












  • try to install it again. maybe will help

    – num8er
    Nov 16 '18 at 7:39











  • While I'm trying to re install the MongoDB service , i'm getting this prompt as an error. service 'MongoDB server'(mongodb) failed to start verify that you have sufficient privileges to start system services.

    – MDIPANJAN
    Nov 16 '18 at 8:16







  • 1





    Thank you. I re installed the MongoDB and at last got the right thing : [nodemon] restarting due to changes... [nodemon] restarting due to changes... [nodemon] starting node app.js listening at port5000 mongodb connected :p

    – MDIPANJAN
    Nov 16 '18 at 10:40

















  • it needs investigation on server. mongoose tries to connect to db and times out. something's wrong with mongodb. seems like Windows Firewall blocking connection. go to control panel and find rule regarding mongodb and allow connections to it

    – num8er
    Nov 16 '18 at 7:26












  • I've downloaded MongoDB 4.0.4 msi package on windows 10, and while i was installing it i think i got some error and skipped that part. Do i need to install It from the scratch again?

    – MDIPANJAN
    Nov 16 '18 at 7:34












  • try to install it again. maybe will help

    – num8er
    Nov 16 '18 at 7:39











  • While I'm trying to re install the MongoDB service , i'm getting this prompt as an error. service 'MongoDB server'(mongodb) failed to start verify that you have sufficient privileges to start system services.

    – MDIPANJAN
    Nov 16 '18 at 8:16







  • 1





    Thank you. I re installed the MongoDB and at last got the right thing : [nodemon] restarting due to changes... [nodemon] restarting due to changes... [nodemon] starting node app.js listening at port5000 mongodb connected :p

    – MDIPANJAN
    Nov 16 '18 at 10:40
















it needs investigation on server. mongoose tries to connect to db and times out. something's wrong with mongodb. seems like Windows Firewall blocking connection. go to control panel and find rule regarding mongodb and allow connections to it

– num8er
Nov 16 '18 at 7:26






it needs investigation on server. mongoose tries to connect to db and times out. something's wrong with mongodb. seems like Windows Firewall blocking connection. go to control panel and find rule regarding mongodb and allow connections to it

– num8er
Nov 16 '18 at 7:26














I've downloaded MongoDB 4.0.4 msi package on windows 10, and while i was installing it i think i got some error and skipped that part. Do i need to install It from the scratch again?

– MDIPANJAN
Nov 16 '18 at 7:34






I've downloaded MongoDB 4.0.4 msi package on windows 10, and while i was installing it i think i got some error and skipped that part. Do i need to install It from the scratch again?

– MDIPANJAN
Nov 16 '18 at 7:34














try to install it again. maybe will help

– num8er
Nov 16 '18 at 7:39





try to install it again. maybe will help

– num8er
Nov 16 '18 at 7:39













While I'm trying to re install the MongoDB service , i'm getting this prompt as an error. service 'MongoDB server'(mongodb) failed to start verify that you have sufficient privileges to start system services.

– MDIPANJAN
Nov 16 '18 at 8:16






While I'm trying to re install the MongoDB service , i'm getting this prompt as an error. service 'MongoDB server'(mongodb) failed to start verify that you have sufficient privileges to start system services.

– MDIPANJAN
Nov 16 '18 at 8:16





1




1





Thank you. I re installed the MongoDB and at last got the right thing : [nodemon] restarting due to changes... [nodemon] restarting due to changes... [nodemon] starting node app.js listening at port5000 mongodb connected :p

– MDIPANJAN
Nov 16 '18 at 10:40





Thank you. I re installed the MongoDB and at last got the right thing : [nodemon] restarting due to changes... [nodemon] restarting due to changes... [nodemon] starting node app.js listening at port5000 mongodb connected :p

– MDIPANJAN
Nov 16 '18 at 10:40












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53332819%2fmongonetworkerror-connection-0-to-localhost27017-timed-out-didnt-understand%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53332819%2fmongonetworkerror-connection-0-to-localhost27017-timed-out-didnt-understand%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Top Tejano songwriter Luis Silva dead of heart attack at 64

政党

天津地下鉄3号線