Mongodb 4.41 does not start in Ubuntu 20.04 - mongodb

I installed Mongodb 4.4.1 following the documentation of the mongodb site. installation was smooth. But when I am checking the status of the mongod service, I am getting an error as below:
Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2020-09-16 22:22:23 IST; 6s ago
Docs: https://docs.mongodb.org/manual
Process: 36655 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, stat> Main PID: 36655 (code=exited, status=14)
Sep 16 22:22:22 Ubuntu-PC systemd[1]: Started MongoDB Database Server.
Sep 16 22:22:23 Ubuntu-PC systemd[1]: mongod.service: Main process
exited, code=exited, s> Sep 16 22:22:23 Ubuntu-PC systemd[1]:
mongod.service: Failed with result 'exit-code'.
Even when I try to open mongo shell typing mongo, I get the following error:
MongoDB shell version v4.4.1 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
The service is showing as started and enabled. Pleas help. Where have I done the mistake. Thanks in advance.

Try this:
service mongod stop
systemctl start mongod
To start using MongoDB:
mongo

Related

couldn't connect to server 127.0.0.1:27017 while trying to start mongodb

After typing mongo
It is showing
MongoDB shell version v5.0.13
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
Also, the MongoDB campus showing connect ECONNREFUSED 127.0.0.1:27017
For mongosh
Current Mongosh Log ID: 6341cd406845432d371fc4b3
Connecting to: mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+1.6.0
MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017
Mongod Service also not starting
root#jahid:/home/jahid# sudo systemctl status mongod
● mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2022-10-09 12:48:22 +06; 9min ago
Docs: https://docs.mongodb.org/manual
Main PID: 28523 (code=exited, status=14)
Oct 09 12:48:21 jahid systemd[1]: Started MongoDB Database Server.
Oct 09 12:48:22 jahid systemd[1]: mongod.service: Main process exited, code=exited, status=14/n/a
Oct 09 12:48:22 jahid systemd[1]: mongod.service: Failed with result 'exit-code'.

Mongod does not start: mongod.service: Failed with result 'signal'

I currently have MongoDB 4.4 installed, as my system does not support 5.0. I have previously had 4.4 installed on Arch Linux, however when I moved over to Ubuntu and tried to run mongod, I get this result from systemd:
● mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)
Active: failed (Result: signal) since Fri 2021-12-10 15:57:00 CST; 2min 3s ago
Docs: https://docs.mongodb.org/manual
Process: 4369 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=killed, signal=ILL)
Main PID: 4369 (code=killed, signal=ILL)
Dec 10 15:57:00 system systemd[1]: Started MongoDB Database Server.
Dec 10 15:57:00 system systemd[1]: mongod.service: Main process exited, code=killed, status=4/ILL
Dec 10 15:57:00 system systemd[1]: mongod.service: Failed with result 'signal'.
MongoDB fails before logs can be created.
While this doesn't completely solve the issue, I'm fine with this resolution:
For whatever reason, 4.2 works fine, but 4.4 doesn't, even though I was completely fine running 4.4 on Arch.

MongoDB does´t start, exit code 203

I installed MongoDB on the Ruspberry pi desktop on a VM, then I started it with the following command:
sudo service mongod start
The result of this command is the following:
systemctl list-unit-files --state enabled
mongodb.service enabled
Then when I check the status using
sudo service mongod status
The other issue is that there´s no .sock file in my /tmp folder.
PS: I removed MongoDB and reinstalled it trying to fix the issue but I always get the same problem.
Can anyone help me please?
Thank you in advance.
I get the following error:
● mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2020-06-08 12:33:17 CEST; 3s ago
Docs: https://docs.mongodb.org/manual
Process: 22168 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=203/EXEC)
Main PID: 22168 (code=exited, status=203/EXEC)
Jun 08 12:33:17 raspberry systemd[1]: Started MongoDB Database Server.
Jun 08 12:33:17 raspberry systemd[22168]: mongod.service: Failed to execute command: Exec format error
Jun 08 12:33:17 raspberry systemd[22168]: mongod.service: Failed at step EXEC spawning /usr/bin/mongod: Exec format error
Jun 08 12:33:17 raspberry systemd[1]: mongod.service: Main process exited, code=exited, status=203/EXEC
Jun 08 12:33:17 raspberry systemd[1]: mongod.service: Failed with result 'exit-code'.```

mongodb version 2.4.9, cannot start mongodb service

I have to install mongodb version 2.4.9 according to project requirement. But I can't start the mongodb service after installing. The error is as follow.
systemctl status mongodb.service
● mongodb.service
Loaded: loaded (/etc/init.d/mongodb; bad; vendor preset: enabled)
Active: failed (Result: exit-code) since ဟူး 2018-03-28 22:04:36 +0630; 28s ago
Docs: man:systemd-sysv-generator(8)
Process: 31482 ExecStart=/etc/init.d/mongodb start (code=exited, status=1/FAILURE)
မတ် 28 22:04:36 ubuntu mongodb[31482]: Rather than invoking init scripts through /etc/init.d, use the service(8)
မတ် 28 22:04:36 ubuntu mongodb[31482]: utility, e.g. service mongodb start
မတ် 28 22:04:36 ubuntu mongodb[31482]: initctl: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
မတ် 28 22:04:36 ubuntu mongodb[31482]: Since the script you are attempting to invoke has been converted to an
မတ် 28 22:04:36 ubuntu mongodb[31482]: Upstart job, you may also use the start(8) utility, e.g. start mongodb
မတ် 28 22:04:36 ubuntu mongodb[31482]: start: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
မတ် 28 22:04:36 ubuntu systemd[1]: mongodb.service: Control process exited, code=exited status=1
မတ် 28 22:04:36 ubuntu systemd[1]: Failed to start mongodb.service.
မတ် 28 22:04:36 ubuntu systemd[1]: mongodb.service: Unit entered failed state.
မတ် 28 22:04:36 ubuntu systemd[1]: mongodb.service: Failed with result 'exit-code'.
Please..
Because sudo -u mongodb /usr/bin/mongod -f /etc/mongodb.conf starts mongod as it should be, there must be something wrong at /etc/init.d/monngodb -script...

Unable to start MongoDB after changing the data directory

I have installed with the help of following link: https://www.digitalocean.com/community/tutorials/how-to-install-mongodb-on-ubuntu-16-04
It was working fine by default. But when I change data directory in /etc/mongod.conf
#From
dbPath: /var/lib/mongodb
#To
dbPath: /media/user/'Mounted Volume'/mongodb_data
I am unable to start MongoDB. Following is the error message
$mongo
MongoDB shell version: 3.2.11
connecting to: test
2017-01-06T00:57:01.472+0530 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2017-01-06T00:57:01.472+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
Following is the status
$ sudo systemctl status mongodb
mongodb.service - High-performance, schema-free document-oriented database
Loaded: loaded (/etc/systemd/system/mongodb.service; enabled; vendor preset:
Active: failed (Result: exit-code) since Fri 2017-01-06 00:56:40 IST; 7s ago
Process: 5735 ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf (cod
Main PID: 5735 (code=exited, status=100)
Jan 06 00:56:40 GL552VW systemd[1]: Started High-performance, schema-free docume
Jan 06 00:56:40 GL552VW systemd[1]: mongodb.service: Main process exited, code=e
Jan 06 00:56:40 GL552VW systemd[1]: mongodb.service: Unit entered failed state.
Jan 06 00:56:40 GL552VW systemd[1]: mongodb.service: Failed with result 'exit-co
I am new to MongoDB. Maybe I am missing something very simple.
From the MongoDB config file documentation page
The Linux package init scripts included in the official MongoDB packages depend on specific values for systemLog.path, storage.dbpath, and processManagement.fork. If you modify these settings in the default configuration file, mongod may not start.
So if you modify these properties in the configuration file, you most probably have to write a new init script.