nodejs application - mongodb connection fails with error "ECONNREFUSED"
I can see in your logs that Mongo is listening on 127.0.0.1. This is likely your problem. You will have to change the bind-ip address configuration setting to allow Mongo to listen to specific or all IP addresses. You can find how to do this here: Cannot connect to mongodb using machine ip
Open a terminal.
Type mongod &
and check the stacktrace.
This is an example of a failing start
I STORAGE [initandlisten] exception in initAndListen: 29 Data directory /data/db not found., terminating I NETWORK [initandlisten] shutdown: going to close listening sockets... I NETWORK [initandlisten] shutdown: going to flush diaglog... I CONTROL [initandlisten] now exiting
To fix this, Create the folder /data/db
In the terminal, type mkdir /data/db
Type againmongod
It works !!
[initandlisten] ** WARNING: Access control is not enabled for the database.I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.I CONTROL [initandlisten] I CONTROL [initandlisten] I CONTROL [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000