Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7530573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:56:52+00:00 2026-05-30T04:56:52+00:00

If I have a mongo instance running, how can I check what port numbers

  • 0

If I have a mongo instance running, how can I check what port numbers it is listening on from the shell? I thought that db.serverStatus() would do it but I don’t see it. I see this

"connections" : {
    "current" : 3,
    "available" : 816

Which is close… but no. Suggestions? I’ve read the docs and can’t seem to find any command that will do this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T04:56:53+00:00Added an answer on May 30, 2026 at 4:56 am

    From the system shell you can use lsof (see Derick’s answer below) or netstat -an to view what a process is actually doing. However, assuming you only have access to the mongo shell (which your question title implies), then you can run the serverCmdLineOpts() command. That output will give you all the arguments passed on the command line (argv) and the ones from the config file (parsed) and you can infer the ports mongod is listening based on that information. Here’s an example:

    db.serverCmdLineOpts()
    {
        "argv" : [
            "./mongod",
            "-replSet",
            "test",
            "--rest",
            "--dbpath",
            "/data/test/r1",
            "--port",
            "30001"
        ],
        "parsed" : {
            "dbpath" : "/data/test/r1",
            "port" : 30001,
            "replSet" : "test",
            "rest" : true
        },
        "ok" : 1
    }
    

    If you have not passed specific port options like the ones above, then the mongod will be listening on 27017 and 28017 (http console) by default. Note: there are a couple of other arguments that can alter ports without being explicit, see here:

    https://docs.mongodb.org/manual/reference/configuration-options/#sharding.clusterRole

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Mongo my understanding is that you can have databases and collections. I'm working
I have an object that has an instance of Doctrine\ODM\MongoDB\Query\Builder . When I serialize
I have an object that was stored via mongo-java-driver. Object uses java.util.UUID for its
I have mongodb running on a remote server. I can ssh to the remote
I have a MongoDB server running on an 64-bit Amazon EC2 instance (journaling enabled).
Currently I have webservice running on the Mono platform. When I call the service
Mono claims to be compatible with .NET. Have you tried it? Can you share
I have recently discovered that I am affected by this bug http://www.mail-archive.com/mono-bugs@lists.ximian.com/msg71515.html Well, at
I'm trying to use mongodb with PHP. For that, I have created a MongoHQ
I have some properties in two bash scripts I want substituted when running mvn

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.