I installed mongodb from this link
When i entermongo in console I got error
root#512son:~# mongo
MongoDB shell version: 2.6.9
connecting to: test
2015-04-10T05:35:23.837+0000 warning: Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2015-04-10T05:35:23.838+0000 Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed at src/mongo/shell/mongo.js:146
exception: connect failed
I searched this problem on internet and i tried:
sudo rm /var/lib/mongodb/mongod.lock
mongod --repair
If i enter mongod in terminal Mongodb work fine but when i close terminal mongodb is closing
I reinstall two times but my problem not fixed
You need to run MongoDB in the background. I mean start mongod as daemon using --fork
Related
I am trying to start a MERN app, I have installed mongo and any relevant things. But when I run mongo in my terminal the following appears.
I have looked across the board but the solutions do not help me. I am also running on Ubuntu 20.04.
MongoDB shell version v4.4.3
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:374:17
#(connect):2:6
exception: connect failed
exiting with code 1
Fixed the issue by running
$ sudo rm -rf /tmp/mongodb-27017.sock
$ sudo service mongod start
Try to start the MongoDB server first running mongod command or from task manager>services> MongoDB server> right-click and start it
Read this Document for more
I am using aws and installed ubuntu server on aws ec2.
I installed mongodb on it.
When installing mongodb, it is working well.
But If i reboot server and try to connect mongod in termina. I am getting the following error.
MongoDB shell version v4.4.0
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:362:17
#(connect):2:6
exception: connect failed
exiting with code 1
So whenever reboot server, i have to execute the following command and then mongo is working again.
sudo systemctl stop mongod
sudo rm /var/lib/mongodb/mongod.lock
sudo mongod --repair --dbpath /var/lib/mongodb
sudo mongod --fork --logpath /var/lib/mongodb/mongodb.log --dbpath /var/lib/mongodb
sudo systemctl start mongod
I think whenever reboot server, executing above command does not make sense.
If anyone have experienced, please help me.
Thanks.
After you setup the mongodb you usually would enable it, so that it starts after each reboot:
sudo systemctl enable mongod
I am trying to run MongoDB in my Ubuntu machine using the following command but I am getting some error.
Command:
mongo
Error:
connecting to: mongodb://127.0.0.1:27017<br>
2019-12-23T17:00:38.815+0530 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: Connection refused<br>
2019-12-23T17:00:38.818+0530 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :<br>
connect#src/mongo/shell/mongo.js:251:13<br>
#(connect):1:6<br>
exception: connect failed
How can I resolve this issue and run MongoDB successfully?
Normally this is caused because you didn't start mongodb service before you try starting mongo shell. You can check for a system service status. If it is failing because of some error try to fix it and start the process. Below are few things that might help with it.
Check if mongodb service is up and running
sudo systemctl status mongodb
If not start mongodb service on your ubuntu machine
sudo systemctl start mongodb
Start mongo shell
mongo
I have issue with Mongo DB start up in ubuntu 14.04 64 bit,its working fine when i installed first time but suddenly from now when i type mongo in ubuntu terminal its showing error:
MongoDB shell version: 3.0.7
connecting to: test
2015-11-26T11:59:03.888+0530 W NETWORK Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2015-11-26T11:59:03.889+0530 E QUERY Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed
at connect (src/mongo/shell/mongo.js:179:14)
at (connect):1:6 at src/mongo/shell/mongo.js:179
exception: connect failed
I tried many solution
i.e
1.deleting lock files, and restart mongo,
2.Change bind ip to 0.0.0.0 in mongod.conf
but my issue still not resolved.
Try to execute the following command to grep process id of mongod to determine if mongo service is running or not
pgrep mongod
If process id exists then please follow the steps as mentioned below
(a) Kill existing mongod process using following command
sudo kill -9 [process_id]
(b) Start mongod process using
sudo mongod --noauth --dbpath /var/lib/mongodb
I'm trying to figure out how to run MongoDB, and am running into the follow error below:
How do I change my IP, do I change this in my mongod.conf? I'm running MongoDB on Virtualbox inside the virtual machine, running Ubuntu 14.04.
2015-01-19T01:02:38.625-0700 warning: Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2015-01-19T01:02:38.625-0700 Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed at src/mongo/shell/mongo.js:146
exception: connect failed
These steps worked for me in getting MongoDB running and I didn't have to mess with changing any IP to match my VM:
1) edited /etc/mongodb.conf changed db-path=data/db
2) created data/db with the following:
sudo mkdir -p /data/db/
sudo chown id -u /data/db
3) ran mongod got an error with the following: Please make at least 3379MB available in /data/db/journal or use --smallfiles
4) re-ran with mongod --small files
5) opened another SSH window and ran mongo
6) mongodb loads - golden