How to Install MongoDB Community Edition 6.0.5 on Debian 11?

MongoDB is a popular document-oriented NoSQL database preferred by many developers because it offers an open-source and free edition named “Community edition”. This database supports numerous operating systems such as Windows, Ubuntu, and Debian. This blog will help the user to install the latest MongoDB Community Edition in Debian 11.

How to Install MongoDB Community Edition 6.0.5 on Debian 11?

MongoDB community’s latest edition is 6.0.5 which can be utilized to store data in the form of documents. The user can install it easily in Debian 11 by following the mentioned steps:

Step 1: Import MongoDB Public GPG Key

To import the GPG key, Debian must have the GnuPG package installed. If it is not available in any case execute this command:

sudo apt install GnuPG


To import the public GPG key of MongoDB from its official website, utilize the wget command:

wget -qO - | \
sudo gpg -o /usr/share/keyrings/mongodb-server-6.0.gpg \


The MongoDB key has been added successfully in Debian 11.

Step 2: Add MongoDB Repository in Debian 11

Run this command to add the MongoDB repository in Debian 11:

echo "deb [ signed-by=/usr/share/keyrings/mongodb-server-6.0.gpg] bullseye/mongodb-org/6.0 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list


The output returned a message after adding the MongoDB repository.

Step 3: Reload the Package Information

After adding the GPG key and repository, it is necessary to update the package information using this command:

sudo apt update


The update of package information has been completed.

Step 4: Install the MongoDB Community Edition 6.0.5

As MongoDB Community Edition 6.0.5 is the latest, users can install the latest edition by executing the command provided below:

sudo apt install -y mongodb-org


Wait for the installation to complete.

However, if the new releases come and the user still wants to install any specific version, such as “5.0.8”, “6.0.4” or “6.0.5”. They need to mention the MongoDB products with the version number individually as shown below:

sudo apt install -y mongodb-org=6.0.5 mongodb-org-database=6.0.5 mongodb-org-server=6.0.5 mongodb-org-mongos=6.0.5 mongodb-org-tools=6.0.5


The output shows that MongoDB Community Edition 6.0.5 is installed.

Step 5: Verify Installation of MongoDB Community Edition 6.0.5

To verify the installation, execute this command to see the version details of the install MongoDB:

mongod --version


The output indicated the details of the installed MongoDB version.

Step 6: Start the MongoDB Service

After the verification, start the MongoDB server service by executing the provided command:

sudo systemctl start mongod

Check the status of the MongoDB server service by running the command given below:

sudo systemctl status mongod


The output showed an error which mostly occurs in Debian 11.

Let us see the procedure to solve this issue in Debian 11.

Resolve this Error

To resolve this error, delete the “/tmp/mongodb-27017.sock ” file using the given command:

sudo chown mongodb:mongodb /tmp/mongodb-27017.sock

Reload the MongoDB server services by running this command:

sudo systemctl daemon-reload

After reloading the server service, start it by executing the command mentioned below:

sudo systemctl status mongod


The output displays that the error is resolved, and the MongoDB server started successfully.

Step 7: Manage the MongoDB Services

The user can stop these server services by running this command:

sudo systemctl stop mongod

After executing the above command run the status command to verify the working of the command.


The output returned the “inactive” status.

To restart these services, utilize the given below command:

sudo systemctl restart mongod

Lastly, run the status command again to see the changes made by the above command:


The output shows that services have been restarted.


To install the latest or specific edition (6.0.5) of the MongoDB Community, import the MongoDB GPG key and add the repository from its official website in Debian 11. After that, check the version details of the installed MongoDB server. In Debian 11, an error occurs after installation on starting the server usually. Follow the steps in the blog to resolve that error. However, users can start, stop, and restart the MongoDB server service.

About the author

Nimrah Ch

I’m a technical writer with a Bachelor's in Software Engineering and Certification in Cyber Security. Through my research and writing, I strive to provide readers with in-depth, informative articles that can help them make informed decisions about their technological needs.