# Elasticsearch Upgarde (Ubuntu)

This article provides detailed instructions for upgrading Elasticsearch to the latest stable version on an Ubuntu system using the APT package manager. It ensures a smooth upgrade while preserving the existing configuration and data.

### **Prerequisites**

* User performing the upgrade has **sudo (administrative) privileges**.
* Elasticsearch is already installed on the system.
* Credentials for the **elastic** user are available (if security is enabled).
* System has **internet connectivity** to fetch updated packages from the repository.

## **Upgrade Steps**

* **Check the Current Version**
  * Run the following command to verify the installed Elasticsearch version:

    ```bash
    curl -XGET -u elastic:<password> http://localhost:9200
    ```
  * Replace `<password>` with the actual password of the **elastic** user.

    <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2F1gknpynK73OcSZDMDx61%2Fimage.png?alt=media&#x26;token=a16612ec-963b-4267-9324-129387193ef1" alt=""><figcaption></figcaption></figure>
* **Stop the Elasticsearch Service**
  * Prevent data corruption by stopping the service before upgrading:<br>

    ```bash
    sudo systemctl stop elasticsearch
    ```

    <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FI1c20D8dwZ5RBguZUeZD%2Fimage.png?alt=media&#x26;token=a1b3a788-5f2e-49d3-9785-43e4481e4b8f" alt=""><figcaption></figcaption></figure>
* **Upgrade Elasticsearch via APT**
  * Update repositories and install the latest version:

    ```bash
    sudo apt update
    sudo apt install elasticsearch -y
    ```

    <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FxyAuqDOY1sdMQcxPUTZk%2Fimage.png?alt=media&#x26;token=ce924c41-7612-414d-b2f5-52a4afe0948c" alt=""><figcaption></figcaption></figure>
  * This fetches the latest version from the configured Elastic APT repository.
* **Start the Elasticsearch Service**
  * Restart the service after installation:

    ```bash
    sudo systemctl start elasticsearch
    ```
* **Verify the Upgrade**
  * Confirm the installed version:

    ```bash
    curl -XGET -u elastic:<password> http://localhost:9200
    ```
  * The response should show the **upgraded version number**.

## **Post-Upgrade Verification (Optional)**

* Check Elasticsearch logs for warnings or errors:

  ```bash
  sudo journalctl -u elasticsearch
  ```
* Confirm the updated version with the API:

  ```bash
  curl -XGET -u elastic:<password> http://localhost:9200
  ```

  <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FutAuGVZsRqsd3QthsDbt%2Fimage.png?alt=media&#x26;token=27c169b5-9808-49cc-a0f8-b1772ce97d72" alt=""><figcaption></figcaption></figure>

***

Copyright © 2025, OvalEdge LLC, Peachtree Corners, GA, USA.
