Mongod.service: Failed with result 'exit-code'

i have been using sudo sytemctl start mongod for while without having issues but lately whenever i run the same command to start mongodb and try to check the status i keep getting this failed message.

mongod.service - MongoDB Database Server
     Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Wed 2022-10-19 20:11:41 WAT; 47min ago
       Docs: https://docs.mongodb.org/manual
    Process: 5770 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=48)
   Main PID: 5770 (code=exited, status=48)

Oct 19 20:11:40  systemd[1]: Started MongoDB Database Server.
Oct 19 20:11:41  systemd[1]: mongod.service: Main process exited, code=exited, status=48/n/a
Oct 19 20:11:41  systemd[1]: mongod.service: Failed with result 'exit-code'.

how do i fix this?

Please share the content of the log file and configuration file.

Also share the output of:

ps -aef | grep [m]ongo
ss -tlnp

If I remember correctly status=48 means you have another process listening at the same address/port.

here’s my config file content Steeve

{"userId":"626bc8fbd5796d38ef89118f","telemetryAnonymousId":"626bc8fbd5796d38ef89118f","enableTelemetry":true,"disableGreetingMessage":true}

ps -aef | grep [m]ongo output

mongodb     2122       1  0 11:12 ?        00:00:07 /usr/bin/mongod --config /etc/mongodb.conf

ss -tlnp

State        Recv-Q        Send-Q                    Local Address:Port                Peer Address:Port       Process                                
LISTEN       0             70                            127.0.0.1:33060                    0.0.0.0:*                                                 
LISTEN       0             4096                          127.0.0.1:27017                    0.0.0.0:*                                                 
LISTEN       0             151                           127.0.0.1:3306                     0.0.0.0:*                                                 
LISTEN       0             511                             0.0.0.0:80                       0.0.0.0:*                                                 
LISTEN       0             32                        192.168.122.1:53                       0.0.0.0:*                                                 
LISTEN       0             4096                      127.0.0.53%lo:53                       0.0.0.0:*                                                 
LISTEN       0             5                             127.0.0.1:631                      0.0.0.0:*                                                 
LISTEN       0             244                           127.0.0.1:5432                     0.0.0.0:*                                                 
LISTEN       0             244                           127.0.0.1:5433                     0.0.0.0:*                                                 
LISTEN       0             244                           127.0.0.1:5434                     0.0.0.0:*                                                 
LISTEN       0             244                           127.0.0.1:5435                     0.0.0.0:*                                                 
LISTEN       0             50                   [::ffff:127.0.0.1]:9614                           *:*           users:(("java",pid=2715,fd=17))       
LISTEN       0             511                                [::]:80                          [::]:*                                                 
LISTEN       0             5                                 [::1]:631                         [::]:* 

please, how do i go about handling the status=48 ?
thanks.

I have been able to fixed the issue.
@steevej
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 if the service has been started by another user.

sudo fuser -k 27017/tcp
1 Like

I am sorry but I did missed the post you made 14 days ago.

Thanks for sharing the solution.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.