Why does the status of mongo throw me (code = exited, status = 48)?
Asked Answered
C

8

15

I am experiencing extreme slowness with mongo. Earlier when I put sudo systemctl status mongodb mongo I appeared Online and in green. Now after a few days he started to throw me away

 mongodb.service - High-performance, schema-free document-oriented database
   Loaded: loaded (/etc/systemd/system/mongodb.service; disabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Fri 2019-11-29 08:55:07 -03; 3 days ago
  Process: 13231 ExecStart = / usr / bin / mongod --quiet --config /etc/mongod.conf (code = exited, status = 48)
 Main PID: 13231 (code = exited, status = 48)

Nov 29 08:55:07 production-power systemd [1]: Started High-performance, schema-free document-oriented database.
Nov 29 08:55:07 production-power systemd [1]: mongodb.service: Main process exited, code = exited, status = 48 / n / a
Nov 29 08:55:07 production-power systemd [1]: mongodb.service: Unit entered failed state.
Nov 29 08:55:07 production-power systemd [1]: mongodb.service: Failed with result 'exit-code'.

This started to happen after an unexpected restart of Google VPS. I think it may be the cause of slowness. In any case, the mongo service is working, so write and read at the base normally nothing but slower. Anyone know how to solve the problem?

Claireclairobscure answered 2/12, 2019 at 14:55 Comment(0)
B
26

Some ubuntu users have a problem with ports

Because the ports will run automatically when the OS opens!

If you have this issue, change the ports will not useful a lot! kill the port of mongod, as a default is => 27017

sudo kill -9 $(sudo lsof -t -i:27017)

then

sudo systemctl start mongod
sudo systemctl status mongod

It will return

● mongod.service - MongoDB Database Server

Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)

Active: active (running) since Tue 2021-08-17 09:47:31 EEST; 2s ago

   Docs: https://docs.mongodb.org/manual

Main PID: 7119 (mongod)

 Memory: 166.7M

 CGroup: /system.slice/mongod.service

         └─7119 /usr/bin/mongod --config /etc/mongod.conf
Basir answered 17/8, 2021 at 6:58 Comment(2)
Thank you, man! This should be the verified answer.Paedogenesis
Thank you, man! I appreciate your kind words <3Basir
S
14

I got error code 48 when i tried to run mongodb.

Here is the output:

sudo service mongod status
● mongod.service - MongoDB Database Server
   Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Tue 2019-12-31 13:15:04 +03; 33min ago
     Docs: https://docs.mongodb.org/manual
 Main PID: 18645 (code=exited, status=48)

Dec 31 13:15:03 cem systemd[1]: Started MongoDB Database Server.
Dec 31 13:15:04 cem systemd[1]: mongod.service: Main process exited, code=exited, status=48/n/a
Dec 31 13:15:04 cem systemd[1]: mongod.service: Failed with result 'exit-code'.

My solution was changing the default port, because this error occurs when the port for MongoDB is already in use.

Step 1: open conf file to edit.

sudo vim /etc/mongod.conf

Step 2: find port and change it.

net: port: 27017 -> default port before any change

After changing port, my issue solved :

sudo service mongod status
● mongod.service - MongoDB Database Server
   Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2019-12-31 13:48:32 +03; 1s ago
     Docs: https://docs.mongodb.org/manual
 Main PID: 25254 (mongod)
   CGroup: /system.slice/mongod.service
           └─25254 /usr/bin/mongod --config /etc/mongod.conf

Dec 31 13:48:32 cem systemd[1]: Started MongoDB Database Server.

I hope this works for you.

Stanislaus answered 31/12, 2019 at 11:1 Comment(1)
I got the same issue after restarting the AWS instance, I don't know why MongoDB does not allow another port besides the default, Thank @cem çetinDelay
P
10

For me the problem was in bindIP. I was trying to configure remote access using bindIp: 127.0.0.1,mongodb_server_ip

So do

sudo nano /etc/mongod.conf

Then

bindIp 127.0.0.1

Then

sudo systemctl start mongod
sudo systemctl status mongod

Result

● mongod.service - MongoDB Database Server
     Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2021-03-03 07:59:40 UTC; 3min 47s ago
       Docs: https://docs.mongodb.org/manual
   Main PID: 910 (mongod)
     Memory: 174.8M
     CGroup: /system.slice/mongod.service
             └─910 /usr/bin/mongod --config /etc/mongod.conf

Mar 03 07:59:40 ip-172-31-17-169 systemd[1]: Started MongoDB Database Server.
Pasadis answered 3/3, 2021 at 8:5 Comment(3)
Well yeah, but now you can only accept connections from the local machine.Arbitration
This did it for me. I have MongoDB running on a Raspberry Pi in my living room. A power outage changed it's local IP, so I had to update the bindIp property with the new local IP. See my other question for details. https://mcmap.net/q/821620/-open-mongodb-to-internal-ipsTyree
This worked for me. I restored an AWS EC2 instance from a snapshot, where the binding IP was the IP of the old EC2 instance that I took the snapshot from. I changed the bindIP to the IP of the new EC2 instance and then the mongo server started successfully.Grof
U
4

I have solved issue through stopping service which is running on the port 27017. This happens especially you run mongod service with root privileges then try to start it again with another user with sudo privileges. So, if you don't mind about the service has been started by another user, you can kill the process on the port you run mongod service, such as:

sudo fuser -k 27017/tcp
Undeceive answered 13/3, 2021 at 13:50 Comment(0)
B
1

In my case mongo wasn't stopped properly previously and had an active process, I had to gracefully kill it and on start all was fine after it.

Bakemeier answered 8/9, 2020 at 12:45 Comment(0)
S
1

I had the same issue, then I realized my docker container port is running on the same port. Either change the docker container port or change the mongo port.

Salliesallow answered 13/7, 2022 at 19:19 Comment(0)
C
0

I have been able to fixed the issue. The mongod service process tries to run on the same port and this was as a result of previously running mongod service with root privileged on ubuntu. I had to kill the process on the port mongod service is listening to without worrying.

sudo fsuer -k 2701/tcp
Cruikshank answered 3/11, 2022 at 11:34 Comment(0)
D
0

I got the same issue after restarting the AWS instance, Because SELinux (Centos) is enabled, in case you change the port to 16027 that not default 27017

allow port and try to start it again

semanage port -a -t mongod_port_t -p tcp 16027
systemctl start mongod
systemctl status mongod
Delay answered 13/7, 2024 at 4:12 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.