How to monitor a TCP port (databases, mail, Redis) in Spot Downtime

A step-by-step guide to TCP port monitoring: pick the host and port, choose an interval, make the port reachable, and test that the alert fires before you rely on it.

· 4 min read · By the Spot Downtime team

Databases, mail servers, Redis and message brokers don't serve web pages, so a website check can't watch them. A TCP port monitor opens a connection to the host and port and alerts you the moment it's refused or times out. It needs no credentials and sends no data.

A TCP check only opens a connection. The answer it gets back decides the result.
TCP port monitors are on every plan, including Free.

Step 1: create the monitor

  1. Open Monitors and click Add monitor.
  2. Choose TCP port.
  3. In Host and port, enter the address with its port, such as db.example.com:5432.
  4. Optionally give it a Name, like Production Postgres. Without one, it's named after the address.
  5. Pick how often to Check every, then click Add monitor.
A TCP monitor for a Postgres database.

Common ports, for reference:

ServicePort
PostgreSQL5432
MySQL / MariaDB3306
Redis6379
SMTP (mail)25, 465 or 587
IMAP993
SSH22

Step 2: make sure the port is reachable

Checks run from the public internet, and private addresses (10.x, 192.168.x and the like) are blocked. If your firewall only accepts connections from your own servers, allow our check addresses. The firewall allowlist guide lists them. You can test from your own machine first:

bash
nc -vz db.example.com 5432

Or use the port checker, which tests from outside your network.

Step 3: read the result

ResultMeans
UpThe connection opened within 10 seconds. The time it took goes on the response-time chart.
Connection refusedThe host is up, but nothing is listening on that port: the service stopped or is bound to another address.
Timed outA firewall dropped the connection, or the host is down.
Host not foundThe hostname doesn't resolve. Check its DNS records.

Step 4: test the alert

  1. Under Alerts, connect a channel such as Slack, email or SMS, and press Send test.
  2. On a staging server, stop the service briefly. The monitor goes down after the failure is confirmed, and you get the alert.
  3. Start it again. You get the recovery alert.

Tips

  • Open port isn't the same as healthy. A database can accept connections while queries fail. For a deeper check, monitor an app endpoint that queries it, with an API monitor.
  • Don't expose a database just to monitor it. If it's private, use a heartbeat from a job that runs inside your network.
  • Domain expiry comes free. A TCP monitor on a domain name also warns you before the domain lapses.

More in this series

Get new guides by email

Practical posts on monitoring, outages, error fixes and on-call, when they're published. No spam.

Unsubscribe from any email with one click. See our privacy policy.

Keep reading