[英]Mean.js not working. Could not connect to MongoDB
SITUATION: 情况:
I downloaded this repository: https://github.com/meanjs/mean 我下载了此存储库: https : //github.com/meanjs/mean
Followed and executed all instructions. 遵循并执行了所有指令。
Did $ npm start
, got the following error: $ npm start
是否出现以下错误:
ERROR: 错误:
Could not connect to MongoDB! { MongoError: failed to connect to server [localhost:27017] on first connect
PS: I did install Mongodb and checked it was working with $ mongod
. PS:我确实安装了Mongodb并检查它是否与$ mongod
一起使用。
EDIT: 编辑:
Full error message if I do $ npm start
: 如果我执行$ npm start
则会出现完整的错误消息:
+ Important warning: config.domain is empty. It should be set to the fully qualified domain of the app.
Could not connect to MongoDB!
{ MongoError: failed to connect to server [localhost:27017] on first connect
at Pool.<anonymous> (/Users/TLL/Desktop/Web Learn/JobBoard/node_modules/mongoose/node_modules/mongodb-core/lib/topologies/server.js:313:35)
at emitOne (events.js:96:13)
at Pool.emit (events.js:188:7)
at Connection.<anonymous> (/Users/TLL/Desktop/Web Learn/JobBoard/node_modules/mongoose/node_modules/mongodb-core/lib/connection/pool.js:271:12)
at Connection.g (events.js:291:16)
at emitTwo (events.js:106:13)
at Connection.emit (events.js:191:7)
at Socket.<anonymous> (/Users/TLL/Desktop/Web Learn/JobBoard/node_modules/mongoose/node_modules/mongodb-core/lib/connection/connection.js:165:49)
at Socket.g (events.js:291:16)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at emitErrorNT (net.js:1278:8)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
name: 'MongoError',
message: 'failed to connect to server [localhost:27017] on first connect' }
(node:5283) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): MongoError: failed to connect to server [localhost:27017] on first connect
/usr/local/bin/node[5283]: ../src/debug-agent.cc:149:void node::debugger::Agent::Stop(): Assertion `(err) == (0)' failed.
1: node::Abort() [/usr/local/bin/node]
2: node::RunMicrotasks(v8::FunctionCallbackInfo<v8::Value> const&) [/usr/local/bin/node]
3: node::debugger::Agent::~Agent() [/usr/local/bin/node]
4: node::debugger::Agent::~Agent() [/usr/local/bin/node]
5: node::Environment::~Environment() [/usr/local/bin/node]
6: node::Start(int, char**) [/usr/local/bin/node]
7: start [/usr/local/bin/node]
[21:34:44] [nodemon] app crashed - waiting for file changes before starting...
Error if I do $ mongo
: 如果我做$ mongo
错误:
MongoDB shell version v3.4.1
connecting to: mongodb://127.0.0.1:27017
2017-01-31T21:41:14.839+0100 W NETWORK [main] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: Connection refused
2017-01-31T21:41:14.840+0100 E QUERY [main] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:234:13
@(connect):1:6
exception: connect failed
Start the MongoDB instance using mongod
in the command line and let it run. 在命令行中使用mongod
启动MongoDB实例,然后使其运行。
Then on another terminal, run npm start
. 然后在另一个终端上,运行npm start
。 MongoDB instance should be run first. MongoDB实例应首先运行。
To see the full options you can pass to mongod
you can check the documentations . 要查看可以传递给mongod
的完整选项,可以查看文档 。
Depending on your operating system, you can search to how you can put the MongoDB instance to be run at boot time, so you don't have to run it manually in a separate window. 根据您的操作系统,您可以搜索如何使MongoDB实例在引导时运行,因此您不必在单独的窗口中手动运行它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.