MongoDB is a leading NoSQL database designed for scalability and flexibility, using a document-oriented model to store data in JSON-like formats. When you deploy a database-ready VPS with HostGraber, we pre-configure the environment so you can start building immediately.
This guide will walk you through verifying that your MongoDB service is installed, secured, and ready for your data.
1. Access Your Server and Retrieve Credentials
To begin, log in to your server via SSH using your server IP and the root credentials provided in your HostGraber Welcome Email.
MongoDB on HostGraber instances is secured with authentication by default. You must retrieve your provisioned admin credentials to gain access.
Run the following command:
cat /root/credential.txt
Look for the ADMIN_USER, ADMIN_PASSWORD, and the CONNECTION_STRING. These are essential for the steps below.
2. Check the Service Status
Ensure the MongoDB daemon (mongod) is active and running on your system.
Command:
systemctl status mongod
-
What to look for: Look for
Active: active (running). If the service is stopped, you can start it withsudo systemctl start mongod.
3. Verify the Network Port
By default, MongoDB listens on Port 27017. Check if the process is bound to this port.
Command:
ss -tulnp | grep 27017
-
Expected Output: You should see a line indicating that
mongodis listening on0.0.0.0:27017or127.0.0.1:27017.
4. Test the Database Connection
Starting with MongoDB 6.0 and 7.0, the legacy mongo shell has been replaced by mongosh (The MongoDB Shell).
Method A: Authenticated Login
Because HostGraber secures your installation, running a plain mongosh command will limit your permissions. Use your credentials from Step 1 to log in as an administrator:
Command:
mongosh -u your_admin_user -p 'your_admin_password' --authenticationDatabase admin
Replace your_admin_user and your_admin_password with the details from your credential file.
Method B: Verify Databases
Once logged in, run the following command inside the shell to ensure you have access:
test> show dbs
If you see a list including admin, config, and local, your installation is functioning perfectly. Type exit to return to the terminal.
5. Verify Version and Environment
To check the specific version of MongoDB and the shell installed on your VPS:
-
Server Version:
mongod --version -
Shell Version:
mongosh --version
Troubleshooting Tips
-
Command 'mongo' not found: This is expected in newer versions (v6.0+). Always use
mongosh. -
Unauthorized Error: If you see
MongoServerError[Unauthorized], it means you tried to run a command without logging in via the-uand-pflags shown in Step 4. -
Firewall: If connecting from an external app, ensure your VPS firewall allows traffic on port 27017.
For further assistance with your NoSQL hosting, visit our support portal at HostGraber.com.
Summary Checklist
| Task | Command |
| Check Shell Version | mongosh --version |
| Check Service Status | systemctl status mongod |
| View Credentials | cat /root/credential.txt |
| Login to Database | mongosh -u admin -p 'password' --authenticationDatabase admin |
Scaling your application? Upgrade to a high-RAM MongoDB Optimized VPS today.