Docker healthcheck failing
05:31 05 Jun 2026

I have a Docker image for a website I am attempting to set up a healthcheck on. As per various answers on Stack Overflow and elsewhere, I've updated the healthcheck to use wget instead of curl, as it is an Alpine image, but it is still failing.

The error message is:

Connecting to localhost:3000 ([::1]:3000) wget: can't connect to remote host: Connection refused

  website:
    image: --IMAGE--
    restart: always
    healthcheck:
      test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3000/"]
      interval: 30s      # Check every 30 seconds
      timeout: 10s       # Fail if check takes longer than 10 seconds
      retries: 3         # Mark unhealthy after 3 consecutive failures
      start_period: 40s  # Grace period for application startup
docker