Old news, just keeping it here for myself.The script comes handy when checking connectivity from containers that do not have curl, wget or nc installed.

bash must be compiled with –enable-net-redirections. This allows bash to handle files in format /dev/tcp/www.google.com/443 or /dev/udp/www.google.com/123

terminal
#!/usr/bin/env bash
#
# bash-healthcheck.sh — probe an HTTP /health endpoint using only bash.
#
# Uses bash's built-in /dev/tcp pseudo-device, so no curl/wget/nc needed.
# Handy for health checks inside minimal containers that only ship bash.
#
# Usage:   ./bash-healthcheck.sh <service> <port> [path]
# Example: ./bash-healthcheck.sh my-service 8443
#          ./bash-healthcheck.sh my-service 8443 /health

set -euo pipefail

service="${1:-}"
port="${2:-}"
path="${3:-/}"

if [[ -z "$service" || -z "$port" ]]; then
  echo "Usage: $0 <service> <port> [path]" >&2
  exit 2
fi

# Open a read/write TCP socket on file descriptor 666.
exec 666<>"/dev/tcp/${service}/${port}"

# Send a minimal HTTP/1.1 request. Connection: close makes the server hang up
# after responding so the read below reaches EOF instead of blocking.
# `\r\n` — CRLF line endings (HTTP requires carriage-return + line-feed).
# `\r\n\r\n` (empty line) marks the end of the headers.
printf 'GET %s HTTP/1.1\r\nHost: %s\r\nConnection: close\r\n\r\n' "$path" "$service" >&666

# Print the server's response (status line, headers and body).
cat <&666

# Close the socket.
exec 666>&-