# Port monitoring for TCP services

Use a port (TCP) monitor to check that a database, mail server, SSH or other service without a web address is accepting connections on its port.

A port monitor checks that a service on a server is accepting connections. A port is a numbered door on a server that one service listens on, such as `5432` for PostgreSQL. The monitor opens a TCP connection, the kind most internet services use, to the host and port and checks that it succeeds.

Use it for services without a web address, such as databases, mail servers, SSH (remote server login), message brokers or game servers. It proves that something is listening on the port and reachable from the internet.

**Before you start**

- You need the **Owner**, **Admin** or **Editor** role in the workspace.
- The port must accept connections from the public internet. If a firewall only allows known sources, see [Firewalls and allowlists](#firewalls-and-allowlists).

## Add a port monitor

1. Open **Monitors** in the sidebar and select **New monitor**.

2. Choose the **Port** tab.

3. In **Host**, enter the server's hostname or IP address, for example `smtp.example.com`, up to 253 characters. Enter the host only, without a scheme or path.

4. In **Port**, enter the port number, from 1 to 65535, for example `587`. See [Common ports](#common-ports) if you are not sure.

5. In **Name**, enter what your team calls the service, for example "Mail submission".

6. Open **Advanced settings** if you want to change **Check every** and **Locations**. See [Create a monitor](/docs/monitors/create/#frequency-and-locations).

7. Under **Test first**, select **Run test** to confirm the port accepts a connection.

8. Select **Create monitor**.

9. Open the monitor's **Notifications** tab and choose who gets alerted. A new monitor alerts nobody until you do.

10. Select **Save changes**.

[Set up alerts for the monitor](/docs/monitors/create/#set-up-alerts-for-the-monitor) covers each alert setting.

The monitor shows **Pending** until its first check reports, then **Up** if the port accepts the connection.

## How a port check works

Each check opens a TCP connection from one of the monitor's locations, taking turns through the locations you selected. The check passes when the connection is established. The check sends no data after the connection opens, so it does not log in, send a command or read the service's greeting.

The response time is the time taken to establish the connection.

StatusCheck re-checks a failure from another location before it marks the monitor **Down**. See [Locations and confirmation](/docs/monitors/regions/).

## Common ports

| Service | Port |
| --- | --- |
| SSH | `22` |
| SMTP, server to server | `25` |
| SMTP submission | `587` |
| PostgreSQL | `5432` |
| MySQL | `3306` |
| Redis | `6379` |

Because the check only opens a connection, a port monitor tells you the service is listening, not that it is healthy. A database can accept connections while refusing queries. If the service has an HTTP health endpoint, add an [HTTP(s) monitor](/docs/monitors/http/) for it as well.

## Firewalls and allowlists

Checks come from StatusCheck's locations on the public internet. A port check sends no `User-Agent` or other identifying data. A firewall that only allows known addresses (an allowlist) blocks the checks, and the monitor reports down.

Opening a database port to the whole internet only to monitor it is rarely a good trade. Monitor a service in front of it instead, such as a health check URL in your app that queries the database. You can make that public safely and watch it with an [HTTP(s) monitor](/docs/monitors/http/).

## Troubleshooting

**The monitor is down, but the service works from inside our network.** The port is not reachable from the internet. Usually a firewall or your cloud provider's security group only allows internal addresses. Test from outside your network, or monitor a public health check URL instead.

**The check fails with a timeout rather than a refused connection.** A firewall is silently ignoring the connection attempts. A refused connection usually means the host is reachable but nothing is listening on that port. Check the port number and that the service is running.

## Related

- [HTTP(s) monitors](/docs/monitors/http/) check that a service answers correctly, not only that it is listening.
- [Ping monitors](/docs/monitors/ping/) check that the host itself is reachable.
- [Locations and confirmation](/docs/monitors/regions/) explains where checks come from.
