Alternatives to ping for checking if a machine is healthy
Codemia Knowledge Hub ·
Firewalls often block ICMP, and some machines disable it, so a failed ping does not prove a machine is down and a successful one says little about its health. Better alternatives are TCP port checks, HTTP requests, SNMP monitoring, application health endpoints and agent-based monitoring tools.
TCP port checks
Try to open a TCP connection to a port the service listens on, such as 80 (HTTP) or 443 (HTTPS) for a web server. A successful connection is a good sign the service is running.
If it connects, you see a blank screen or a message. If it fails, the service may be down or blocked.
HTTP requests with curl or wget
For web servers, an HTTP request tells you much more than ping. curl or wget return status codes that reflect the service's health:
This fetches only the headers. "200 OK" means the service is up; "5xx" responses mean server errors.
SNMP monitoring
With Simple Network Management Protocol, an agent on each device collects operational and performance data. An SNMP manager queries the agents for metrics such as CPU usage, disk space and network throughput.
Custom health check endpoints
Many applications expose an HTTP endpoint that returns a status code and often a JSON payload with health details:
Response:
Agent-based monitoring tools
Zabbix, Nagios and Prometheus use agents on the server to run detailed checks, covering everything from hardware metrics to application logs.
Comparing the options
| Method | Description | Pros | Cons |
| TCP Port Checks | Test open ports using tools like telnet. | Simple and fast. | Does not provide detailed health metrics. |
| HTTP Requests | Send HTTP requests to get server responses. | Detailed responses. | Limited to HTTP services. |
| SNMP Monitoring | Retrieves metrics via SNMP. | Comprehensive system metrics. | Requires SNMP setup. |
| Custom Health Checks | Endpoints returning detailed health status. | Very detailed; application-specific. | Needs endpoint implementation. |
| Agent-based Monitoring | Agents report metrics to a central system. | Deep insights into system health. | Requires installation and configuration. |
Combining methods gives the most complete picture: TCP port checks for a quick first pass, and monitoring agents for in-depth, ongoing analysis.
Related reading
- Amazon EC2 ELB alarm - which instance is unhealthy?
- Amazon EC2 ssh timeout due inactivity
- Amazon Elastic Beanstalk - Change Timezone
- Amazon Elastic Beanstalk node and npm non-standard install locations
- an error occurred forwarding 9090 - 9090 error forwarding port 9090
- An error occurred LogGroup - resource name already exists while trying to deploy Serverless
- analysing network traffic
- Android development environment in Docker
System design interview problems on this topic
- Design a Metrics Monitoring and Alerting System: solution and walkthrough
- Design a Distributed Tracing System: solution and walkthrough
- Design a Code Deployment System: solution and walkthrough
- Design GitHub Actions: solution and walkthrough

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseSystem Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.