# 默认的MongoDB端口

下表列出了MongoDB使用的默认TCP端口:

| Default Port | Description                                                                                                                                                                                                                                                                                                                                                          |
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `27017`      | [`mongod`](https://docs.mongodb.com/master/reference/program/mongod/#bin.mongod)和[`mongos`](https://docs.mongodb.com/master/reference/program/mongos/#bin.mongos)实例的默认端口。您可以使用[`port`](https://docs.mongodb.com/master/reference/configuring-options/#net.port)或[`——port`](https://docs.mongodb.com/master/reference/program/mongod/#%20cmdop-mongod%20-port)来更改该端口。 |
| `27018`      | 默认端口为[`mongod`](https://docs.mongodb.com/master/reference/program/mongod/%20bin.mongod)运行[**——shardsvr**](https://docs.mongodb.com/master/reference/program/mongod/%20#%20cmdoption-mongod-shardsvr)命令行选项或 **shardsvr** 值[**clusterRole**](https://docs.mongodb.com/master/reference/configuration-options/%20#%20sharding.clusterRole)设置在配置文件中。                     |
| `27019`      | 默认端口为[`mongod`](https://docs.mongodb.com/master/reference/program/mongod/%20bin.mongod)运行[**——configsvr**](https://docs.mongodb.com/master/reference/program/mongod/%20#%20cmdoption-mongod-configsvr)命令行选项或 **configsvr** 值[**clusterRole**](https://docs.mongodb.com/master/reference/configuration-options/%20#%20sharding.clusterRole)设置在配置文件中。                  |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mongoing.com/can-kao/default-mongodb-port.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
