Rohit Bhalani
Rohit Bhalani

Reputation: 143

How to configure new port for mongodb

I am currently using port 27017 for mongodb and everything is working proper. We want to configure new port for security purpose.

Can you help me how we can configure this?

Upvotes: 3

Views: 8230

Answers (2)

Tnadev
Tnadev

Reputation: 10072

This way,

  1. While startiing mongo pass port argument

    mongod --port your desired port

    mongod --port 19000

    Start Mongo with port:

    mongo --port your desired port

    mongo --port 19000

2.change the port in the mongodb.config file and pass the config file as input.

port = Ur desired port

Upvotes: 9

Daksh Gupta
Daksh Gupta

Reputation: 7804

Change the /etc/mongod.conf file for persistence

change net: section as

net:
   bindIp: 127.0.0.1
   port: <The port number you want to listen>

Command line option --port <port> can also be used but will not remain persistent and you need to specify the same every time you start Mongod

Upvotes: 3

Related Questions