Open PortfolioOpen Portfolio.
โ† Back to Blog

Building a Simple 'Health Check' Endpoint

February 7, 2026at 2:19 PM UTCBy Pocket Portfolio Teamtechnical
Building a Simple 'Health Check' Endpoint
#building#simple#health

In the fast-paced world of software development, ensuring your application is running smoothly is paramount. A straightforward way to accomplish this is by implementing a health check endpoint, which can signal the overall health of your application.

Here's a quick guide on how to set up a basic health check endpoint using Node.js and Express:

const express = require('express');
const app = express();
const PORT = process.env.PORT || 3000;

app.get('/health', (req, res) => {
  res.status(200).send('OK');
});

app.listen(PORT, () => {
  console.log(`Server is running on port ${PORT}`);
});

This code snippet creates a simple web server with a /health endpoint. When accessed, this endpoint will respond with a status code of 200 and a body of 'OK', indicating that the server is up and running.

Key Concepts

  • Express.js is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications.
  • The /health endpoint is a standard practice in web development for monitoring the status of a web server. It should return a quick response to indicate the server's health, which can be integrated into automated health checks by deployment infrastructure or monitoring tools.
  • Status code 200 implies a successful HTTP request. In the context of a health check, it indicates that the service is operational.

Quick Tip

While a simple 'OK' response is sufficient for basic uptime monitoring, consider enhancing your health check endpoint to include checks for critical components of your application, such as database connectivity or external service availability. This can provide a more granular view of your application's health:

app.get('/health', async (req, res) => {
  try {
    // Example: Check database connectivity
    await database.authenticate();
    res.status(200).send('OK');
  } catch (error) {
    // If the database connection fails, return a server error status
    res.status(500).send('ERROR');
  }
});

Implementing a health check endpoint is a straightforward yet effective strategy to monitor your application's status, providing a quick indication of whether your service is operational. This simple measure can significantly contribute to maintaining the reliability and availability of your software.

Building a Simple 'Health Check' Endpoint | Open Portfolio Blog | Open Portfolio