Back to All Articles
MonitoringOct 18, 20268 min read

TCP Port Monitoring: How to Check Redis, PostgreSQL, and SMTP Availability

HTTP monitors cannot check backend infrastructure. Learn how to use TCP Port Monitoring to directly ping Redis, PostgreSQL, RabbitMQ, and SMTP servers to detect microservice failures before APIs crash.

P
Prabin Jha
Founder & Lead Architect
LinkedIn

Key Takeaways (BLUF)

Bottom Line Up Front (BLUF): Standard HTTP uptime monitors are excellent for testing the front door of your API, but they are blind to the backend infrastructure. If your Redis cache or PostgreSQL database crashes, the HTTP API might just return a generic 500 Internal Server Error, leaving engineers scrambling to identify the root cause. TCP Port Monitoring solves this by establishing direct, low-level socket connections to your internal infrastructure ports (e.g., 5432, 6379, 25). This allows you to pinpoint exact database or message queue failures instantly, drastically reducing Mean Time to Resolution (MTTR).

The Blind Spot of HTTP Monitoring

A modern microservice architecture consists of dozens of interconnected components. A typical Node.js API might rely on a PostgreSQL database for state, a Redis cluster for caching, and a RabbitMQ broker for asynchronous task processing.

If an external HTTP monitor queries `api.yourcompany.com/health` and receives a 500 Error, the on-call engineer is paged. However, the alert lacks context. Is the Node.js process dead? Did the database run out of connections? Did the Redis instance OOM (Out of Memory)?

The engineer must SSH into servers, tail logs, and manually debug the stack to find the broken link. This diagnostic phase wastes precious minutes during a critical outage. TCP Port Monitoring eliminates this diagnostic phase by continuously asserting the availability of individual backend components.

What is a TCP Port Monitor?

Instead of sending an HTTP GET request and waiting for a 200 OK status code, a TCP monitor operates at Layer 4 of the OSI model.

It attempts to complete a standard 3-way TCP handshake (SYN, SYN-ACK, ACK) with a specific IP address and port. If the handshake is successful, the monitor immediately closes the connection and records a "healthy" ping. If the connection is refused (ConnectionRefused) or times out, the monitor flags the port as down.

Because it does not require application-level protocols (like HTTP or SQL authentication), a TCP monitor is incredibly lightweight and can be executed at very high frequencies (e.g., every 15 seconds) with near-zero impact on the target server's resources.

  • Pinpoint Diagnostics: Instantly know exactly which database or queue crashed, rather than guessing from a generic API 500 error.
  • Low Resource Overhead: Layer 4 handshakes require a fraction of the compute and memory compared to executing an HTTP request or a SQL query.
  • Protocol Agnostic: TCP monitors can check literally any service that binds to a port, including proprietary legacy systems, game servers, and IoT device endpoints.

Common Ports for Infrastructure Monitoring

When setting up an internal observability mesh, you should deploy internal TCP monitors across your VPC (Virtual Private Cloud) targeting the following standard ports:

ServiceDefault PortWhy You Must Monitor It
PostgreSQL5432Detect database crashes, connection pool exhaustion, or underlying host network failures.
Redis6379Identify Out-of-Memory (OOM) kills or cache eviction crashes before the API grinds to a halt.
RabbitMQ / AMQP5672Ensure message brokers are accepting connections so background workers do not stall.
SMTP25 / 587 / 465Verify that mail servers are reachable for sending critical password resets and invoices.
Elasticsearch9200Ensure search clusters are responsive and accepting indexing requests.

Implementing TCP Monitoring Behind a Firewall

The primary challenge of TCP monitoring is that databases and caches should NEVER be exposed to the public internet.

If you use a hosted monitoring platform like WakeMetrics, you cannot simply point a TCP monitor at `redis.yourcompany.internal:6379`. To solve this, you have two secure options:

1. IP Whitelisting: Expose the specific port on your firewall, but strictly whitelist only the static IP addresses of the WakeMetrics probe servers. This ensures only the monitoring platform can perform the TCP handshake.

2. Internal VPC Probes: Deploy a lightweight, containerized monitoring agent inside your private VPC. The agent performs the TCP handshakes locally against your private IPs and pushes the telemetry data outward to the hosted dashboard.

# A quick way to manually test a TCP handshake from your terminal using netcat (nc):
# Usage: nc -vz <hostname> <port>

$ nc -vz db.yourcompany.internal 5432
Connection to db.yourcompany.internal port 5432 [tcp/postgresql] succeeded!

# If the database is down or firewalled:
$ nc -vz db.yourcompany.internal 5432
nc: connect to db.yourcompany.internal port 5432 (tcp) failed: Connection refused

Frequently Asked Questions

Does a TCP check verify that my database data is correct?

No. A TCP check only verifies that the server process (e.g., PostgreSQL) is running and accepting network connections. It does not authenticate or run SQL queries.

Can a TCP check cause connection pool exhaustion?

If configured aggressively without closing connections, yes. However, proper TCP monitors (like those in WakeMetrics) immediately send a FIN or RST packet to gracefully close the socket the moment the handshake succeeds.

Conclusion

Stop guessing which part of your stack is broken. By layering internal TCP Port Monitors beneath your external HTTP monitors, you gain X-ray vision into your infrastructure. When an incident occurs, you will immediately know whether it is a database failure, a cache crash, or a web server issue, allowing your team to resolve the outage in record time. Start monitoring your backend ports with WakeMetrics/signup/page.tsx).

Ready to Upgrade from UptimeRobot?

Migrate in under 60 seconds. Get 15-second checks across 450+ global locations with zero false alerts.