How to Reset a Forgotten Elasticsearch 8.x/9.x Password Safely
When the built‑in elastic user password is lost in Elasticsearch 8.x or 9.x, you can use the official elasticsearch‑reset‑password command‑line tool to generate or set a new password without restarting the service, following a few simple steps and troubleshooting tips.
Problem
In Elasticsearch 8.x or 9.x, forgetting the password of a built‑in user such as elastic prevents login to the management console, showing “Username or password is incorrect. Please try again.”
Solution
Elasticsearch provides the elasticsearch-reset-password command‑line tool, which can reset built‑in user passwords without restarting the cluster.
Procedure
1. Open a shell in the Elasticsearch bin directory
cd /your/elasticsearch/path/bin2. Run the reset command
Method 1 – Auto‑generate a strong password
./elasticsearch-reset-password -u elasticThe tool prints a newly generated password to the terminal.
Method 2 – Manually specify a new password (recommended)
./elasticsearch-reset-password -i -u elasticThe tool prompts for the new password and its confirmation.
Method 3 – Specify HTTPS URL
./elasticsearch-reset-password -i -u elastic --url https://localhost:9200Adjust the URL, port, and hostname to match the HTTPS endpoint.
3. Follow the prompts
Enter and confirm the new password.
Command line reports “Password for the [elastic] user successfully reset.”
Common Issues
Command not found : Execute the command from the Elasticsearch bin directory.
Cluster health abnormal : Add the -f flag to force execution after resolving health problems.
HTTPS certificate errors : Use the --url option with a correct HTTPS address or verify certificate configuration.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Mingyi World Elasticsearch
The leading WeChat public account for Elasticsearch fundamentals, advanced topics, and hands‑on practice. Join us to dive deep into the ELK Stack (Elasticsearch, Logstash, Kibana, Beats).
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
