0
0
ElasticsearchHow-ToBeginner · 3 min read

How to Start Elasticsearch: Quick Guide for Beginners

To start Elasticsearch, first ensure it is installed on your system. Then run the elasticsearch command in your terminal or use the service manager to start it as a background service. Once running, you can access it via http://localhost:9200.
📐

Syntax

Starting Elasticsearch depends on your operating system and installation method. Common ways include:

  • Command line: Run elasticsearch to start the server manually.
  • Service manager: Use systemctl start elasticsearch on Linux systems with systemd.
  • Docker: Use docker run with the Elasticsearch image.

Each method launches the Elasticsearch server, which listens on port 9200 by default.

bash
elasticsearch

# Or on Linux with systemd
sudo systemctl start elasticsearch

# Or with Docker
sudo docker run -d -p 9200:9200 -e "discovery.type=single-node" elasticsearch:8.9.0
💻

Example

This example shows how to start Elasticsearch manually from the command line and verify it is running by querying its status.

bash
# Start Elasticsearch (run in terminal)
elasticsearch

# In another terminal, check if it's running
curl http://localhost:9200

# Expected JSON response:
{
  "name" : "your-node-name",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "some-uuid",
  "version" : {
    "number" : "8.9.0",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "somehash",
    "build_date" : "2024-06-01T00:00:00.000Z",
    "build_snapshot" : false,
    "lucene_version" : "9.7.0",
    "minimum_wire_compatibility_version" : "8.0.0",
    "minimum_index_compatibility_version" : "8.0.0"
  },
  "tagline" : "You Know, for Search"
}
Output
{ "name" : "your-node-name", "cluster_name" : "elasticsearch", "cluster_uuid" : "some-uuid", "version" : { "number" : "8.9.0", "build_flavor" : "default", "build_type" : "tar", "build_hash" : "somehash", "build_date" : "2024-06-01T00:00:00.000Z", "build_snapshot" : false, "lucene_version" : "9.7.0", "minimum_wire_compatibility_version" : "8.0.0", "minimum_index_compatibility_version" : "8.0.0" }, "tagline" : "You Know, for Search" }
⚠️

Common Pitfalls

Some common mistakes when starting Elasticsearch include:

  • Not having Java installed or configured properly (Elasticsearch bundles its own Java since version 7, so this is rare now).
  • Trying to start Elasticsearch without proper permissions.
  • Port 9200 already in use by another process.
  • Not setting discovery.type=single-node when running a single-node cluster in Docker, causing startup failure.

Always check the logs in logs/ folder or system journal for errors.

bash
# Wrong: Starting Docker without single-node setting
sudo docker run -d -p 9200:9200 elasticsearch:8.9.0

# Right: Add single-node discovery for local testing
sudo docker run -d -p 9200:9200 -e "discovery.type=single-node" elasticsearch:8.9.0
📊

Quick Reference

CommandDescription
elasticsearchStart Elasticsearch server manually from terminal
sudo systemctl start elasticsearchStart Elasticsearch as a service on Linux with systemd
curl http://localhost:9200Check if Elasticsearch is running and get cluster info
docker run -d -p 9200:9200 -e "discovery.type=single-node" elasticsearch:8.9.0Run Elasticsearch in Docker as single-node cluster

Key Takeaways

Run the 'elasticsearch' command or use your system's service manager to start Elasticsearch.
Verify Elasticsearch is running by accessing http://localhost:9200 in your browser or via curl.
Use 'discovery.type=single-node' when running Elasticsearch in Docker for local testing.
Check logs or system journal if Elasticsearch fails to start.
Ensure no other process is using port 9200 before starting Elasticsearch.