connection to mongo db failed - node.js

failed to to connect to mongo. Very new to this need help please.
this is what i get:
MongoDB shell version: 3.2.9
connecting to: test
2016-09-12T00:09:34.516+0100 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, reason: errno:10061 No connection could be made because the target machine actively refused it.
2016-09-12T00:09:34.517+0100 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect#src/mongo/shell/mongo.js:229:14
#(connect):1:6
exception: connect failed

Related

Mongodb error: couldn't connect to server 127.0.0.1:27017 connection refused

I downloaded mongodb-bin and mongodb-tools-bin in AUR.I just typed sudo systemctl enable mongodb and just ran mongo.This is the error i got:
$ mongo
MongoDB shell version v5.0.5
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect#src/mongo/shell/mongo.js:372:17
#(connect):2:6
exception: connect failed
exiting with code 1
I saw somebody say to just delete /var/lib/mongodb/mongod.lock but when i checked there was no mongod.lock file
I have fixed the problem by deleting /tmp/mongodb-27017.sock.I have found the answer here

Mongo shutting down with error code(1) after running the mongo command

I am new to MongoDB and I keep getting a SocketException and a shutting down with exit code : 1
error. I have also tried stopping and restarting the mongod servers. The error I get is as follows :
root#sam-sepiol:~# mongo
MongoDB shell version v4.2.8
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
2020-07-01T08:19:45.406-0400 E QUERY [js] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect#src/mongo/shell/mongo.js:341:17
#(connect):2:6
2020-07-01T08:19:45.407-0400 F - [main] exception: connect failed
2020-07-01T08:19:45.407-0400 E - [main] exiting with code 1

Can't run mongo on ubuntu 18.04

I'm new on Mongodb, and after I run mongo, I get :
MongoDB shell version v4.2.1
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
2019-12-08T20:59:51.774+0100 E QUERY [js] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect#src/mongo/shell/mongo.js:341:17
#(connect):2:6
2019-12-08T20:59:51.775+0100 F - [main] exception: connect failed
2019-12-08T20:59:51.775+0100 E - [main] exiting with code 1
Please any help!!

Failed to connect to mlab Database

I'm trying to connect to my database on mlab through mongodb.
I have cd to mongodb directory, then I run the code and all I get is this error. If I try to connect over localhost it's fine but on real server I get the error below:
./bin/mongo ds151508.mlab.com:51508/dansql -u xx -p xxx
MongoDB shell version v3.6.3
connecting to: mongodb://ds151508.mlab.com:51508/dansql
2018-02-28T09:31:17.748-0700 W NETWORK [thread1] Failed to connect to 34.228.213.238:51508, in(checking socket for error after poll), reason: Connection refused
2018-02-28T09:31:17.749-0700 E QUERY [thread1] Error: couldn't connect to server ds151508.mlab.com:51508, connection attempt failed :
connect#src/mongo/shell/mongo.js:251:13
#(connect):1:6
exception: connect failed

Cannot connect with Mongo

When I try to launch the mongo shell running the 'mongo' command in the terminal I get this error:
connecting to: mongodb://127.0.0.1:27017
2017-12-23T17:52:51.318+0100 W NETWORK [thread1] Failed to connect to
127.0.0.1:27017, in(checking socket for error after poll), reason:
Connection refused
2017-12-23T17:52:51.319+0100 E QUERY [thread1] Error: couldn't connect to
server 127.0.0.1:27017, connection attempt failed :
connect#src/mongo/shell/mongo.js:237:13
#(connect):1:6
exception: connect failed
I cannot figur out what is the problem...
First, you need to check whether mongo server is running on your local system by visiting below url in the browser.
http://127.0.0.1:27017
you can run the below command in case of ubuntu.
$ sudo service mongod start
Then, Run:
$ mongo

Resources