MongoDB VPS - Getting Started Guide
Your MongoDB VPS based on Ubuntu 24.04 comes fully configured - MongoDB 8.0 is installed with the admin password you specified during order. mongo-express is included for web-based database management. You can create databases and users through mongo-express or the command line.
Software Included
| Component | Version |
|---|---|
| Ubuntu | 24.04 LTS |
| MongoDB | 8.0 Community (official APT) |
| mongosh | included with MongoDB |
| Node.js | 20 LTS |
| mongo-express | latest (npm) |
| Apache | 2.4 (reverse proxy) |
| Certbot | latest |
| Fail2Ban | latest |
Step 1 - Get Your Server Credentials
Log in to your client panel and open your VPS service details. You will need:
- IP address of your server
- Root password (for SSH access)
Your MongoDB admin password is the one you entered during the order. Login: admin.
Step 2 - Access mongo-express
mongo-express is a web-based admin interface for MongoDB, available immediately after your VPS is created:
http://your.server.ip/mongo-express
Log in with HTTP Basic Auth credentials:
- Username:
admin - Password: the MongoDB Admin Password you entered during the order
With mongo-express you can browse databases, view and edit documents, run queries and manage collections without using the command line.
Step 3 - Connect to MongoDB Remotely
MongoDB is configured to accept remote connections with authentication. You can connect from any application or tool:
mongosh "mongodb://admin:your_admin_password@your.server.ip:27017/admin"
Connection details for MongoDB GUI tools (MongoDB Compass, Studio 3T, etc.). Note: Port 27017 is the MongoDB wire protocol, not HTTP - it cannot be opened in a browser. Use a database client or the command above.
| Parameter | Value |
|---|---|
| Host | your.server.ip |
| Port | 27017 |
| Username | admin |
| Password | Admin Password (from order) |
| Auth Database | admin |
Connection string format:
mongodb://admin:your_admin_password@your.server.ip:27017/admin
Step 4 - Enable SSL (Optional)
If you have a domain pointing to this server, you can enable HTTPS for mongo-express with a free Let's Encrypt certificate. Connect via SSH:
ssh root@your.server.ip
/opt/setup/get-ssl.sh db.yourdomain.com
The script will verify DNS, obtain a certificate and configure Apache for HTTPS automatically. After completion, mongo-express is available at https://db.yourdomain.com/mongo-express.
Note: Make sure your domain's A record points to the server IP before running the script. SSL is optional - mongo-express works fine over HTTP with IP address access.
What's Pre-Configured
- Authentication: MongoDB authorization is enabled with SCRAM-SHA-256. Admin user has root privileges
- Remote access: MongoDB accepts connections from any IP on port 27017
- WiredTiger cache: Automatically tuned to 50% of available RAM on first boot
- Security: Fail2Ban protects SSH and mongo-express from brute-force attacks
- Web interface: mongo-express runs behind Apache reverse proxy at /mongo-express
Database Management
Creating Additional Databases and Users
You can create additional databases and users via mongo-express or SSH:
mongosh -u admin -p --authenticationDatabase admin
use newdb
db.createUser({
user: "newuser",
pwd: "strong_password",
roles: [{ role: "readWrite", db: "newdb" }]
})
Import and Export
Via mongo-express: Use the web interface to view and edit individual documents.
Via command line (recommended for bulk operations):
# Export entire database
mongodump -u admin -p your_admin_password --authenticationDatabase admin -d your_database -o /tmp/backup/
# Import database
mongorestore -u admin -p your_admin_password --authenticationDatabase admin -d your_database /tmp/backup/your_database/
# Export single collection to JSON
mongoexport -u admin -p your_admin_password --authenticationDatabase admin -d your_database -c your_collection -o collection.json
# Import JSON into collection
mongoimport -u admin -p your_admin_password --authenticationDatabase admin -d your_database -c your_collection --file collection.json
Post-Installation
Fail2Ban - Brute-Force Protection
Your server comes with Fail2Ban pre-configured to protect both SSH and mongo-express from brute-force attacks.
| Rule | Max Attempts | Ban Duration |
|---|---|---|
| SSH | 5 failed logins | 10 minutes |
| mongo-express | 5 failed logins | 1 hour |
Useful commands:
# Check banned IPs
fail2ban-client status mongo-express
fail2ban-client status sshd
# Unban an IP
fail2ban-client set mongo-express unbanip 1.2.3.4
If you accidentally lock yourself out, connect via VNC console in your client panel and unban your IP.
MongoDB Performance Tuning
WiredTiger cache is automatically set to 50% of RAM on first boot. To check the current value:
mongosh -u admin -p --authenticationDatabase admin --eval "db.serverStatus().wiredTiger.cache"
To adjust manually, edit /etc/mongod.conf (under storage.wiredTiger.engineConfig.cacheSizeGB) and restart MongoDB:
systemctl restart mongod
Server Credentials
MongoDB credentials are stored in /root/.mongo_credentials. This file contains the admin password and mongo-express login credentials.
Updates
MongoDB and the OS don't update automatically. To update manually:
apt update && apt upgrade -y
Troubleshooting
| Problem | Solution |
|---|---|
| Can't connect to MongoDB remotely | Check that port 27017 is not blocked by firewall. Verify the user exists and has correct authenticationDatabase |
| mongo-express shows 401 Unauthorized | Use username admin and the MongoDB Admin Password from your order. Credentials are in /root/.mongo_credentials |
| mongo-express page doesn't load | Check service: systemctl status mongo-express. Restart: systemctl restart mongo-express |
| Authentication failed | Make sure to specify --authenticationDatabase admin. The admin user authenticates against the admin database |
| MongoDB won't start | Check logs: journalctl -u mongod -n 50. Common cause: disk full (df -h /) or invalid YAML in mongod.conf |
| Forgot MongoDB admin password | SSH in and check /root/.mongo_credentials |
| Blocked by Fail2Ban | Use VNC console in your client panel to unban your IP |