Health Checks & Restarts
Keep the service alive and self-healing.
Health Checks & Restarts is a free MCP Academy lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the MCP Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Servers Need a Pulse
A deployed server can hang or crash silently. A health check is a simple probe that answers the question: are you still alive? 🩺
Expose a Health Endpoint
The classic pattern is a tiny route, often /health, that returns 200 OK when the server is ready to handle work.
GET /health -> 200 OKKeep the Check Cheap
A health check runs constantly, so keep it lightweight. It should confirm the process responds without doing heavy real work.
Liveness vs Readiness
Two ideas matter: liveness asks is the process alive, while readiness asks is it ready to accept traffic yet. They can differ at startup.
Let Docker Watch It
Docker can run a HEALTHCHECK on a schedule. If the command fails enough times, the container is marked unhealthy.
HEALTHCHECK CMD curl -f http://localhost:8000/health || exit 1Restart on Failure
A restart policy tells the platform to bring a dead container back automatically, so a single crash does not mean downtime.
docker run --restart unless-stopped my-mcp-serverOrchestrators Do This Too
Tools like Kubernetes use the same probes to restart unhealthy pods and to route traffic only to ready instances.
Avoid Restart Loops
If a server crashes instantly on boot, blind restarts just loop forever. Use backoff so retries slow down and you can see the real error.
Check Dependencies Wisely
A deep readiness check can ping a database, but be careful: if every server marks itself unready at once, an outage can cascade.
Drain Before You Stop
On shutdown, stop accepting new calls but let in-flight ones finish. This graceful drain prevents cutting clients off mid-request.
Self-Healing in Practice
Health checks plus restart policies give you a self-healing service that recovers from most failures with no human awake at 3am. 🌙
Quick Check
What is the difference between a liveness and a readiness check?
Recap: Health & Restarts
A cheap /health endpoint plus a restart policy makes your server self-healing: probes catch failures and the platform brings it back. 💪
Frequently asked questions
Is the “Health Checks & Restarts” lesson free?
Yes — the full text of “Health Checks & Restarts” is free to read here on the web, and the MCP Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the MCP Academy course, upgrade to CoddyKit PRO.
What will I learn in “Health Checks & Restarts”?
Keep the service alive and self-healing. You practise MCP Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start MCP Academy?
No prior experience is required. MCP Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Health Checks & Restarts” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this MCP Academy lesson?
Yes. Every MCP Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Package the Server in Docker
- Run Behind a Reverse Proxy
- Health Checks & Restarts
- Connect Remote Clients