Reputation: 1
events.js:160 throw er; // Unhandled 'error' event
^
MongoError: failed to connect to server [localhost:27017] on first connect [MongoError: connect ECONNREFUSED 127.0.0.1:27017]
at Pool.<anonymous>
(C:\Users\DELL\Desktop\meanapp\server\node_modules\mongodb-
core\lib\topologies\server.js:328:35)
at emitOne (events.js:96:13)
at Pool.emit (events.js:188:7)
at Connection.<anonymous>
(C:\Users\DELL\Desktop\meanapp\server\node_modules\mongodb-
core\lib\connection\pool.js:274:12)
Upvotes: 0
Views: 1000
Reputation: 13960
The error is saying that the connection have been refused (ECONNREFUSED). There is no endpoint listening on 127.0.0.1:27017
Mongo have a client-server architecture. Before connecting to the database, you need to start the database server. First, create a folder to store the data files. Then, from command prompt, go to where your mongo installations resides and write:
mongod --port 27017 --dbpath C:\path_to_data_folder
https://docs.mongodb.com/manual/tutorial/manage-mongodb-processes/
Upvotes: 0