# TCP

> The TCP check - whether a port accepts a connection, with its fields, limits and failure codes.

A TCP check opens a connection to a host and port and closes it. It passes when the connection is accepted within the check's timeout. Nothing is sent over it.

```json
{ "type": "tcp", "host": "db.example.com", "port": 5432 }
```

| Field  | Type    | Default  | Rules                          |
| ------ | ------- | -------- | ------------------------------ |
| `host` | string  | required | An IP address or a domain name |
| `port` | integer | required | 1 to 65535                     |

The host's addresses are checked against the [node's address rules](https://docs.monitorly.cloud/concepts/nodes.md#what-platform-nodes-may-not-reach): a database or another service on an internal address needs a [private node](https://docs.monitorly.cloud/nodes/install.md).

A failed run says why: `dns.nxdomain` or `dns.failed` when the name does not resolve, `tcp.refused` when nothing listens on the port, `tcp.unreachable` when there is no route, `timeout` when no answer came in time ([Run results and error codes](https://docs.monitorly.cloud/checks/results.md)).
