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
    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


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                            *                                                 
LISTEN       0             4096                          *                                                 
LISTEN       0             151                            *                                                 
LISTEN       0             511                                *                                                 
LISTEN       0             32                           *                                                 
LISTEN       0             4096                         *                                                 
LISTEN       0             5                               *                                                 
LISTEN       0             244                            *                                                 
LISTEN       0             244                            *                                                 
LISTEN       0             244                            *                                                 
LISTEN       0             244                            *                                                 
LISTEN       0             50                   [::ffff:]: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 ?

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 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.