Port 27017 (TCP) is the default port of MongoDB (mongod and mongos); sharded clusters also use 27018 and 27019. Since MongoDB 3.6 the server binds to localhost by default, but databases opened to the internet without authentication were mass-wiped by ransom bots in 2017. Keep 27017 on a private network and enable authentication and TLS.
Free online tool — ping & port checker: instant results, no signup.
Port 27017 is reserved for MongoDB. MongoDB database. Unauthenticated open = mass ransomware 2017-18. Loopback/VPC only.
Close the port if the service isn't used. For admin ports, require IP whitelist or VPN. Monitor connection attempts via fail2ban.
MongoDB is a NoSQL database designed for scalability and flexibility, which has gained immense popularity due to its ability to handle large volumes of unstructured data. The default communication port for MongoDB is 27017. This port is used for client-server communication, allowing applications to connect to the database server to perform CRUD (Create, Read, Update, Delete) operations.
When a MongoDB server is launched without any configuration changes, it listens on 27017 for incoming connections. This default behavior means that if MongoDB is deployed in a public-facing environment without proper security measures, it can become a target for malicious actors. Particularly during the ransomware waves of 2017-2018, many MongoDB instances were found exposed on the internet with no authentication, leading to mass data breaches and ransom demands.
To mitigate these risks, it is advisable to limit access to port 27017 by implementing network security measures, such as:
Additionally, MongoDB provides built-in security features, such as authentication and authorization, which should be enabled to safeguard your data.
Securing MongoDB, especially when it operates on the default port 27017, is crucial to prevent unauthorized access and potential data breaches. Here are some best practices to enhance the security of your MongoDB deployment:
security.authorization to enabled in the mongod.conf configuration file.27017. Only allow connections from trusted IP addresses or networks.bindIp setting in mongod.conf. For example:net: bindIp: 127.0.0.1, By following these best practices, you can significantly reduce the risk associated with running MongoDB on port 27017 and protect your sensitive data from unauthorized access.
Configuring MongoDB to operate securely on port 27017 involves several command-line operations and modifications to the configuration file. Below are practical commands and configurations to enhance your MongoDB setup:
To start MongoDB with authentication enabled, you can use the following command:
mongod --auth --port 27017 --dbpath /data/db Ensure that you have created an admin user before enabling authentication.
Edit the mongod.conf file to include the following settings:
net: port: 27017 bindIp: 127.0.0.1, After starting MongoDB without authentication, create an admin user with the following commands:
use admin db.createUser({user: 'admin', pwd: 'your-password', roles: [{role: 'userAdminAnyDatabase', db: 'admin'}]}) To enable TLS/SSL, start MongoDB with the following command:
mongod --port 27017 --sslMode requireSSL --sslPEMKeyFile /path/to/your/certificate.pem These commands and configurations will help you set up a secure MongoDB environment on port 27017, ensuring that your database is protected from unauthorized access and potential attacks.
Every open port is a potential entry point. If the service isn't used — close it.
Free plan — 10 monitors, checks every 5 min, no card required. Upgrade for 1-minute interval and multi-region monitoring.