MongoDB – How to change the default port of mongodb?

By default mongodb instance run on port 27017.

There are two options to change the default port of mongodb.

  1. pass the –port argument when we start mongod.
  2. change the port in the mongodb.config file and pass the config file as input.

To connect to mongod running on port 19000 we need to start the mongo also with –port argument.

Alternatively you can change the port in /etc/mongodb.config

Leave a comment

Your email address will not be published. Required fields are marked *