I have followed this steps and install MongoDB in my Linux mint and finally run this command
mongo --host 127.0.0.1:27017
But got this error after run this command.
MongoDB shell version: 3.2.18
connecting to: 127.0.0.1:27017/test
2017-12-21T13:16:20.693+0530 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: errno:111 Connection refused
2017-12-21T13:16:20.693+0530 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect#src/mongo/shell/mongo.js:231:14
#(connect):1:6
exception: connect failed
I have already run this command also
sudo service mongod start
But after this command,
mongod.service - High-performance, schema-free document-oriented database
Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset:
Active: failed (Result: exit-code) since Thu 2017-12-21 13:35:28 IST; 6s ago
Docs: https://docs.mongodb.org/manual
Process: 4891 ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf (cod
Main PID: 4891 (code=exited, status=100)
I found many solution but did not get it resolved. Thanks in advance.
Make sure mongod service is running locally
sudo service mongod status
and if it's not, run sudo service mongod start
If that doesn't help, try this:
sudo rm /var/lib/mongodb/mongod.lock
sudo mongod --repair
and run service mongod start again
EDIT
Try changing permissions in the mongodb folder
cd /var/lib/mongodb
sudo chown -R mongodb:mongodb *
Also, If that doesn't help, run this
sudo /usr/bin/mongod --config /etc/mongodb.conf
and tell me the output (If it works is doesn't solve your problem, the service startup still needs to be fixed, just curious)
Related
Getting this error when I try to run command mongo:
MongoDB shell version v4.0.0
connecting to: mongodb://127.0.0.1:27017
2018-07-24T13:08:13.968+0800 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:251:13
#(connect):1:6
exception: connect failed
After run this command sudo service mongod status Its giving me output something like this :
mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
Active: failed (Result: core-dump) since Sel 2018-07-24 13:18:18 +08; 45s ago
Docs: https://docs.mongodb.org/manual
Process: 18153 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=dumped, signal=ABRT)
Main PID: 18153 (code=dumped, signal=ABRT)
root#him: systemd[1]: Started MongoDB Database Server.
root#him: mongod[18153]: 2018-07-24T13:18:18.777+0800 I CONTROL [main] Automatically disabling TLS 1.0, to f
root#him: mongod.service: Main process exited, code=dumped, status=6/ABRT
root#him: mongod.service: Unit entered failed state.
root#him: mongod.service: Failed with result 'core-dump'.
The data files are created under root not the mongodb user when you run from the terminal.
You need to give permissions:
cd /var/lib/mongodb
sudo chown -R mongodb:mongodb *
Hope this helps.
I had the same error, maybe because of ubuntu upgrade from 18.04 to 20.04. Could not start mongod manually, the reason was absence of /data/db and its permissions. Then mongod would start manually but still errorring on mongodb.service. At the end reinstalling mongodb worked. It was a new install so did not care about backups.
$ sudo apt remove mongodb mongo-tools mongodb-clients mongodb-server mongodb-server-core
$ sudo apt autoremove
$ sudo rm -rf /var/lib/mongodb/
$ sudo apt install mongodb
I am getting this error instead of my shell prompt (running Ubuntu 16.04LTS).
I'm pretty new to MongoDB. I had to downgrade from version 3.4 to 3.2:
https://docs.mongodb.com/manual/release-notes/3.4-downgrade-standalone/
I followed those instructions (I thought) pretty faithfully, but now can't access the shell to confirm, etc.
scorpian555#scorpo:~$ mongo
MongoDB shell version: 3.2.15
connecting to: test
2017-07-13T14:41:31.434-0400 W NETWORK [thread1] Failed to connect to
127.0.0.1:27017, in(checking socket for error after poll), reason:
errno:111 Connection refused
2017-07-13T14:41:31.434-0400 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
There was a socket file that the error seems to be referencing at /tmp/mongodb-27017.sock
Per these, I ended up removing that socket file, then tried to reboot the mongod daemon:
'Failed to unlink socket file" error in MongoDB 3.0
MongoDB - Permission denied for socket: /tmp/mongodb-27017.sock
service mongod restart
service mongod status
scorpian555#scorpo:~$ service mongod status
● mongod.service - High-performance, schema-free document-oriented
database
Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor
preset: enabled)
Active: active (running) since Thu 2017-07-13 14:58:08 EDT; 4s ago
Docs: https://docs.mongodb.org/manual
Main PID: 4763 (mongod)
CGroup: /system.slice/mongod.service
└─4763 /usr/bin/mongod --quiet --config /etc/mongod.conf
Jul 13 14:58:08 scorpo systemd[1]: Started High-performance, schema-
free document-oriented database.
Per those, I removed the socket file and ran:
scorpian555#scorpo:~$ ls -ld /tmp
drwxrwxrwt 17 root root 20480 Jul 13 14:58 /tmp
I think I'm a little lost here, I was under the impression that, upon restart of the daemon, it would recreate this temporary file, at which point I would check the permissions.
I can't find the link at the moment, but had found elsewhere instructions to make sure the owner of the mongod.sock file was mongod (not root) and I would have to chown it if it wasn't mongod.
I'm pretty new to MongoDB, like I said. I found this as another possible issue, but wanted to see if I should dive down this rabbit hole or whether I might be looking in the wrong place?
Connection refused to MongoDB errno 111
Thanks.
My issue was that, while I started the mongod service, I did not actually run the daemon with sudo as needed.
I'm trying to connect to a remote mlab database. Everything works fine, except for some times I simply can’t connect to the database. It might have something to do with my computer since my test server can connect to it without any problems. Nevertheless I can’t figure out what the problem might be. I went through their connection troubleshooting guide but already got stuck at the first step
nc -w 3 -v ds119568.mlab.com 19568
gives the following error:
nc: connectx to ds119568.mlab.com port 19568 (tcp) failed: Operation timed out
Trying to connect via mongo shell gives this error:
MongoDB shell version v3.4.3
connecting to: mongodb://ds119568.mlab.com:19568/ba
2017-07-08T15:05:04.528+0200 W NETWORK [thread1] Failed to connect to
54.73.159.50:19568 after 5000ms milliseconds, giving up.
2017-07-08T15:05:04.533+0200 E QUERY [thread1] Error: couldn't
connect to server ds119568.mlab.com:19568, connection attempt failed :
connect#src/mongo/shell/mongo.js:237:13
#(connect):1:6
exception: connect failed
Advice what on what could be the problem here? Does it have something to do with the firewall of my computer?
This worked for me (Ubuntu 16.04) :
sudo systemctl start mongod
Doesn't give output. Check the status to verify that the service has started properly.
sudo systemctl status mongod
Output should be something like:
● mongod.service - High-performance, schema-free document-oriented database
Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)
Active: active (running) since Fri 2017-02-17 18:57:26 UTC; 17min ago
Docs: https://docs.mongodb.org/manual
Main PID: 2811 (mongod)
Tasks: 17
Memory: 56.8M
CPU: 7.294s
CGroup: /system.slice/mongod.service
└─2811 /usr/bin/mongod --quiet --config /etc/mongod.conf
Verify that its running:
sudo systemctl enable mongod
Output should be:
Created symlink from /etc/systemd/system/multi-user.target.wants/mongod.service
to /lib/systemd/system/mongod.service.
Then you should be able to connect to mongo shell.
mongo
For more refer to this link: https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-mongodb-on-ubuntu-16-04
i installed mongodb in ubuntu usinfg the following links
https://askubuntu.com/questions/724749/install-mongo-3-2-on-ubuntu-15-10
root#karthickeyan:/home/karthickeyan# mongo
MongoDB shell version: 3.2.9
connecting to: test
2016-08-20T01:17:08.198+0530 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2016-08-20T01:17:08.198+0530 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
Create the file /lib/systemd/system/mongod.service with the following content:
[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target
[Service]
User=mongodb
ExecStart=/usr/bin/mongod --quiet --config /etc/mongodb.conf
[Install]
WantedBy=multi-user.target
Start the service:
sudo service mongodb start
Then run the command:
mongo
You will then access the server. Hope it works for you. :)
I have installed MongoDB:
user#user-workshop:~$ sudo service mongodb restart
stop: Unknown instance:
mongodb start/running, process 7980
user#user-workshop:~$ mongo
MongoDB shell version: 2.0.4
connecting to: test
Mon Mar 3 21:43:33 Error: couldn't connect to server 127.0.0.1 shell/mongo.js:84
exception: connect failed
user#user-workshop:~$
but as you can see, I'm unable to connect to it. What can I do about it?
Try running these commands:
rm /data/db/mongod.lock
mongod --dbpath /data/db --repair
mongod --dbpath /data/db
For more details read: mongodb manual