Loading...

Check for responsive Elasticsearch instance in a shell script

:heavy_exclamation_mark: This post is older than a year. Consider some information might not be accurate anymore. :heavy_exclamation_mark:

This small shell script checks if an Elasticsearch instance is running by querying the REST API.

#!/usr/bin/env bash
PORT=9200
URL="http://localhost:$PORT"
# Check that Elasticsearch is running
curl -s $URL 2>&1 > /dev/null
if [ $? != 0 ]; then
    echo "Unable to contact Elasticsearch on port $PORT."
    echo "Please ensure Elasticsearch is running and can be reached at $URL"
    exit -1
fi
Please remember the terms for blog comments.