Unable to connect to mongodb when running express app
up vote
0
down vote
favorite
I am new to programming and am currently learning MEAN. Basically I am getting the following error message below when trying to run nodemon server from home. This problem does not happen when I'm at school or at my local Starbucks. Can someone please take a look at the following error I'm getting MongoNetworkError: getaddrinfo ENOTFOUND localhost localhost:27017 and help me understand why I can't connect to mongoDB? For clarification, yes I do have mongod running on a separate terminal. I am running macOS High Sierra -v 10.13.4 on a 2011 macbook pro. Please help me. Thank you.
Here's the error I get when starting my server:
[nodemon] starting
node server
(node:27636) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
listening on port 8000
(node:27636) UnhandledPromiseRejectionWarning: MongoNetworkError: failed to connect to server [localhost:27017] on first connect [MongoNetworkError: getaddrinfo ENOTFOUND localhost localhost:27017]
at Pool.
(/Users/ROBONYX21/Desktop/Angular/product_list/node_modules/mongodb-core/lib/topologies/server.js:564:11)
at Pool.emit (events.js:182:13)
at Connection. >(/Users/ROBONYX21/Desktop/Angular/product_list/node_modules/mongodb-core/lib/connection/pool.js:317:12)
at Object.onceWrapper (events.js:273:13)
at Connection.emit (events.js:182:13)
at Socket. >(/Users/ROBONYX21/Desktop/Angular/product_list/node_modules/mongodb-core/lib/connection/connection.js:246:50)
at Object.onceWrapper (events.js:273:13)
at Socket.emit (events.js:182:13)
at emitErrorNT (internal/streams/destroy.js:82:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
at process._tickCallback (internal/process/next_tick.js:63:19)
(node:27636) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:27636) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
This is what's showing on the terminal running mongod mongod port 27017
2018-11-22T09:48:15.268-0800 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten]
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten]
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten] ** WARNING: This server is bound to localhost.
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten] ** Remote systems will be unable to connect to this server.
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning.
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten]
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten]
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
2018-11-22T09:48:22.917-0800 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
2018-11-22T09:48:23.545-0800 I NETWORK [initandlisten] waiting for connections on port 27017
Here is my node.js file in which I'm connecting to the mongoose db.
mongoose.js
node.js mongodb express
add a comment |
up vote
0
down vote
favorite
I am new to programming and am currently learning MEAN. Basically I am getting the following error message below when trying to run nodemon server from home. This problem does not happen when I'm at school or at my local Starbucks. Can someone please take a look at the following error I'm getting MongoNetworkError: getaddrinfo ENOTFOUND localhost localhost:27017 and help me understand why I can't connect to mongoDB? For clarification, yes I do have mongod running on a separate terminal. I am running macOS High Sierra -v 10.13.4 on a 2011 macbook pro. Please help me. Thank you.
Here's the error I get when starting my server:
[nodemon] starting
node server
(node:27636) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
listening on port 8000
(node:27636) UnhandledPromiseRejectionWarning: MongoNetworkError: failed to connect to server [localhost:27017] on first connect [MongoNetworkError: getaddrinfo ENOTFOUND localhost localhost:27017]
at Pool.
(/Users/ROBONYX21/Desktop/Angular/product_list/node_modules/mongodb-core/lib/topologies/server.js:564:11)
at Pool.emit (events.js:182:13)
at Connection. >(/Users/ROBONYX21/Desktop/Angular/product_list/node_modules/mongodb-core/lib/connection/pool.js:317:12)
at Object.onceWrapper (events.js:273:13)
at Connection.emit (events.js:182:13)
at Socket. >(/Users/ROBONYX21/Desktop/Angular/product_list/node_modules/mongodb-core/lib/connection/connection.js:246:50)
at Object.onceWrapper (events.js:273:13)
at Socket.emit (events.js:182:13)
at emitErrorNT (internal/streams/destroy.js:82:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
at process._tickCallback (internal/process/next_tick.js:63:19)
(node:27636) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:27636) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
This is what's showing on the terminal running mongod mongod port 27017
2018-11-22T09:48:15.268-0800 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten]
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten]
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten] ** WARNING: This server is bound to localhost.
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten] ** Remote systems will be unable to connect to this server.
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning.
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten]
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten]
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
2018-11-22T09:48:22.917-0800 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
2018-11-22T09:48:23.545-0800 I NETWORK [initandlisten] waiting for connections on port 27017
Here is my node.js file in which I'm connecting to the mongoose db.
mongoose.js
node.js mongodb express
can you turn off your antivirus (if any) and firewall also can you attach your nodejs file where you're making connection.
– Vaibhav Kumar Goyal
Nov 23 at 4:00
You are being asked for code which is "text". Not a picture. And you were given a warning when you attempted to add the picture exactly for that reason. Copy the text of the code into your question. See How to create a Minimal, Complete, and Verifiable example
– Neil Lunn
Nov 23 at 8:35
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am new to programming and am currently learning MEAN. Basically I am getting the following error message below when trying to run nodemon server from home. This problem does not happen when I'm at school or at my local Starbucks. Can someone please take a look at the following error I'm getting MongoNetworkError: getaddrinfo ENOTFOUND localhost localhost:27017 and help me understand why I can't connect to mongoDB? For clarification, yes I do have mongod running on a separate terminal. I am running macOS High Sierra -v 10.13.4 on a 2011 macbook pro. Please help me. Thank you.
Here's the error I get when starting my server:
[nodemon] starting
node server
(node:27636) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
listening on port 8000
(node:27636) UnhandledPromiseRejectionWarning: MongoNetworkError: failed to connect to server [localhost:27017] on first connect [MongoNetworkError: getaddrinfo ENOTFOUND localhost localhost:27017]
at Pool.
(/Users/ROBONYX21/Desktop/Angular/product_list/node_modules/mongodb-core/lib/topologies/server.js:564:11)
at Pool.emit (events.js:182:13)
at Connection. >(/Users/ROBONYX21/Desktop/Angular/product_list/node_modules/mongodb-core/lib/connection/pool.js:317:12)
at Object.onceWrapper (events.js:273:13)
at Connection.emit (events.js:182:13)
at Socket. >(/Users/ROBONYX21/Desktop/Angular/product_list/node_modules/mongodb-core/lib/connection/connection.js:246:50)
at Object.onceWrapper (events.js:273:13)
at Socket.emit (events.js:182:13)
at emitErrorNT (internal/streams/destroy.js:82:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
at process._tickCallback (internal/process/next_tick.js:63:19)
(node:27636) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:27636) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
This is what's showing on the terminal running mongod mongod port 27017
2018-11-22T09:48:15.268-0800 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten]
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten]
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten] ** WARNING: This server is bound to localhost.
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten] ** Remote systems will be unable to connect to this server.
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning.
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten]
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten]
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
2018-11-22T09:48:22.917-0800 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
2018-11-22T09:48:23.545-0800 I NETWORK [initandlisten] waiting for connections on port 27017
Here is my node.js file in which I'm connecting to the mongoose db.
mongoose.js
node.js mongodb express
I am new to programming and am currently learning MEAN. Basically I am getting the following error message below when trying to run nodemon server from home. This problem does not happen when I'm at school or at my local Starbucks. Can someone please take a look at the following error I'm getting MongoNetworkError: getaddrinfo ENOTFOUND localhost localhost:27017 and help me understand why I can't connect to mongoDB? For clarification, yes I do have mongod running on a separate terminal. I am running macOS High Sierra -v 10.13.4 on a 2011 macbook pro. Please help me. Thank you.
Here's the error I get when starting my server:
[nodemon] starting
node server
(node:27636) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
listening on port 8000
(node:27636) UnhandledPromiseRejectionWarning: MongoNetworkError: failed to connect to server [localhost:27017] on first connect [MongoNetworkError: getaddrinfo ENOTFOUND localhost localhost:27017]
at Pool.
(/Users/ROBONYX21/Desktop/Angular/product_list/node_modules/mongodb-core/lib/topologies/server.js:564:11)
at Pool.emit (events.js:182:13)
at Connection. >(/Users/ROBONYX21/Desktop/Angular/product_list/node_modules/mongodb-core/lib/connection/pool.js:317:12)
at Object.onceWrapper (events.js:273:13)
at Connection.emit (events.js:182:13)
at Socket. >(/Users/ROBONYX21/Desktop/Angular/product_list/node_modules/mongodb-core/lib/connection/connection.js:246:50)
at Object.onceWrapper (events.js:273:13)
at Socket.emit (events.js:182:13)
at emitErrorNT (internal/streams/destroy.js:82:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
at process._tickCallback (internal/process/next_tick.js:63:19)
(node:27636) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:27636) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
This is what's showing on the terminal running mongod mongod port 27017
2018-11-22T09:48:15.268-0800 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten]
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten]
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten] ** WARNING: This server is bound to localhost.
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten] ** Remote systems will be unable to connect to this server.
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning.
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten]
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten]
2018-11-22T09:48:20.581-0800 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
2018-11-22T09:48:22.917-0800 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
2018-11-22T09:48:23.545-0800 I NETWORK [initandlisten] waiting for connections on port 27017
Here is my node.js file in which I'm connecting to the mongoose db.
mongoose.js
node.js mongodb express
node.js mongodb express
edited Nov 23 at 8:33
Neil Lunn
96.4k22169180
96.4k22169180
asked Nov 22 at 17:05
cM_R
11
11
can you turn off your antivirus (if any) and firewall also can you attach your nodejs file where you're making connection.
– Vaibhav Kumar Goyal
Nov 23 at 4:00
You are being asked for code which is "text". Not a picture. And you were given a warning when you attempted to add the picture exactly for that reason. Copy the text of the code into your question. See How to create a Minimal, Complete, and Verifiable example
– Neil Lunn
Nov 23 at 8:35
add a comment |
can you turn off your antivirus (if any) and firewall also can you attach your nodejs file where you're making connection.
– Vaibhav Kumar Goyal
Nov 23 at 4:00
You are being asked for code which is "text". Not a picture. And you were given a warning when you attempted to add the picture exactly for that reason. Copy the text of the code into your question. See How to create a Minimal, Complete, and Verifiable example
– Neil Lunn
Nov 23 at 8:35
can you turn off your antivirus (if any) and firewall also can you attach your nodejs file where you're making connection.
– Vaibhav Kumar Goyal
Nov 23 at 4:00
can you turn off your antivirus (if any) and firewall also can you attach your nodejs file where you're making connection.
– Vaibhav Kumar Goyal
Nov 23 at 4:00
You are being asked for code which is "text". Not a picture. And you were given a warning when you attempted to add the picture exactly for that reason. Copy the text of the code into your question. See How to create a Minimal, Complete, and Verifiable example
– Neil Lunn
Nov 23 at 8:35
You are being asked for code which is "text". Not a picture. And you were given a warning when you attempted to add the picture exactly for that reason. Copy the text of the code into your question. See How to create a Minimal, Complete, and Verifiable example
– Neil Lunn
Nov 23 at 8:35
add a comment |
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',
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53435577%2funable-to-connect-to-mongodb-when-running-express-app%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53435577%2funable-to-connect-to-mongodb-when-running-express-app%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
can you turn off your antivirus (if any) and firewall also can you attach your nodejs file where you're making connection.
– Vaibhav Kumar Goyal
Nov 23 at 4:00
You are being asked for code which is "text". Not a picture. And you were given a warning when you attempted to add the picture exactly for that reason. Copy the text of the code into your question. See How to create a Minimal, Complete, and Verifiable example
– Neil Lunn
Nov 23 at 8:35