MongoDB Server of course run on TCP port 27017. Be that as it may, you can change the mongodb port on the off chance that you need.
In this instructional exercise I will disclose How to change mongodb port on both Linux and Microsoft Windows Operating framework.
Changing mongodb default port additionally changes the HTTP status interface port, which as a matter of course is 28017. The web status port is consistently accessible on a port that is X+1000, where X addresses the worker port.
In this post, We will change the MongoDB default port 27017 to other port number due to security reason.
Step 1: Verify the MongoDB Running Port
You need to check default port number in mongoDB main config file and also we can use the netstat command for the same.
sudo vim /etc/mongod.conf
On line number 23, You get the port configuration parameter and you need to change it as per your requirement, In my case i am going use 27018 port number.
Save and exit from the text editor.
Step 2: Restart the MongoDB Service
To get new changes for port configuration, We need to restart the MongoDB service by using the following command.
sudo systemctl restart mongod
Step 3: Verify Port
Now we are ready to get the port number by using the netstat command like this.
netstae -plntu | grep 27018
if everything is okay, So then you will the output like this.
As per the screen shoot, We can see that out updated port is showing for MongoDB.
We have successfully change default MongoDB’s port server on ubuntu machine, Still you have any issue leave a comment.