Have you just got MongoDB Error shutting down with code:48?

This is an error message that MongoDB users often get when the port for MongoDB is already in use.

So, to fix involves finding the already running process or assigning a different port for MongoDB.

At Bobcares, we get many requests to fix MongoDB errors, as a part of our Server Management Services.

Today, let’s see how our Database Engineers fix the MongoDB error code 48.

 

What does the MongoDB error code 48 indicate?

Before getting deeper into the error, it’s important to get a brief idea about MongoDB. Basically, MongoDB works as a non-relational database under the banner NoSQL.

MongoDB is a cross-platform, document-oriented database. Basically, it works on the concept of collections and documents. Here documents are structures composed of files and key-value pairs. Furthermore, a collection is a group of documents.

Usually, it stores data in JSON style document. MongoDB is a schema-less database with deep query-ability. This makes non-tabular databases like MongoDB, one of a popular database in big data applications.

But MongoDB errors are always troublesome. Usually, MongoDB shows up codes and status before exiting. One such error code is shutting down with code:48.

Basically, the code indicates that newly started MongoDB could not listen to incoming connections, due to an error.

Here the process ended because the port for the MongoDB is already in use.

 

How we fix the MongoDB error 48?

From our experience in managing servers, there are two options through which our Support Engineers fix this error. That is, either kill the process that is using the default MongoDB port. Or else, assign a different port for mongod service.

 

1. Use the default MongoDB port

When a customer approaches us with this error, firstly our Support Team checks the running process in the MongoDB port.

If some other services are using the default mongod port, then it shows error 48. So, to check this we use the command,

lsof -i | grep 27017

27017 is the default port for MongoDB. If the server has MongoDB running at another port, we replace the port number with a custom one.

So, if some other process is found to use the port 27017, we kill it using the command,

kill <PID>

Here, PID denotes the process ID of the process running on 27017.

In most cases, this fixes the error and MongoDB starts working again.

 

2. Change the mongod to a custom port

Another best option to fix this error is to change the default port to a custom port. Port conflicts can appear in the server when multiple services work on the same box.

Therefore, to fix the problem, our Support Engineers change the mongod port using the command,

mongod --port 27018

Now the mongod service will start running in the newly assigned port. And the error doesn’t show up again.

 

[Having difficulty in fixing MongoDB errors? – We have the right expertise.]

 

Conclusion

In short, MongoDB error code 48 indicates that the default port of MongoDB is already in use. So fix involves stopping the process that is already using the port or assigning a new port for MongoDB. Today, we saw how our Support Engineers fix this error.



Source link

Author

Write A Comment