Uninstall  Elasticsearch

Steps to fully uninstall Elasticsearch from your server

How to uninstall Elasticsearch on a linux server isn’t well documented. Here’s a clear set of instruction on how to do it.

Find Running Elasticsearch Instances

First confirm that Elasticsearch is not actively running.

Using curl

Check for a running server on the machine’s localhost with curl:

curl localhost:9200

If one is you’ll see a response containing elasticsearch.

Using ps

Check for a running server process using ps:

ps -ef | grep elas

If one exists you’ll see it returned, if you don’t see anything then no elasticsearch process is running.

Stop/Shutdown a Running Elasticsearch Process

To stop a running process use the service command. First check if a service exists using the following command:

sudo service elasticsearch status

If you found any actively running elasticsearch processes in the previous step then you can shut it down using one of the following approaches:


curl -XPOST https://localhost:9200/_cluster/nodes/_shutdown


killall -KILL elas


sudo service elasticsearch stop

Uninstall Elasticsearch

Depending on how elasticsearch was installed, and what type of server you’re running, you’ll need to use one of the following approaches to uninstall it.


The apt-get command is usually found on Ubuntu, Debian, and related Linux distributions.

sudo apt-get remove elasticsearch


The rpm command is typically found on Red Hat linux machines like CentOS and Fedora.

rpm -e elasticsearch


The yum command exists on Red Hat linux machines using Red Hat Enterprise Linux RPM software packages.

sudo yum remove elasticsearch

Purging an Elasticsearch Config

The final step to uninstall elasticsearch from a server is to clear out the leftover configuration files.


sudo apt-get --purge autoremove elasticsearch


sudo dpkg --purge elasticsearch

If you receive any errors and need to force the removal you can add a --force-all argument to the command:

sudo dpkg --purge --force-all elasticsearch

Final Step for a Clean Uninstall

The final step for a super clean uninstall is to manually remove the following directories that are leftover on the system:

sudo rm -rf /var/lib/elasticsearch/
sudo rm -rf /etc/elasticsearch

You can also remove the service script, but the location will vary from server to server.


These steps may change over time, or may not work on your system. It’s important that you know what you’re doing and take full responsibility for the outcome of this process. I may no guarantee or warranty on any of this advice, use it at your own risk.

Meet the Author

Kevin Leary, WordPress Consultant

I'm a custom WordPress web developer and analytics consultant in Boston, MA with 17 years of experience building websites and applications. View a portfolio of my work or request an estimate for your next project.