# How to reset elasticsearch "elastic" user password?

**URL:** <https://discuss.elastic.co/t/how-to-reset-elasticsearch-elastic-user-password/371673>\
**Category:** Elasticsearch\
**Created:** [December 9, 2024, 6:43am UTC](https://discuss.elastic.co/t/how-to-reset-elasticsearch-elastic-user-password/371673 "2024-12-09T06:43:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![aalaskapedh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aalaskapedh/32/139800_2.png) [@aalaskapedh](https://discuss.elastic.co/u/aalaskapedh)\
**Post date:** [December 9, 2024, 6:43am UTC](https://discuss.elastic.co/t/how-to-reset-elasticsearch-elastic-user-password/371673/1 "2024-12-09T06:43:15Z")

</div>

`install-elasticsearch.sh`

```auto
sudo dnf install -y java-17-openjdk java-17-openjdk-devel
sudo rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
cat << EOF > /etc/yum.repos.d/elasticsearch.repo
[elasticsearch]
name=Elasticsearch repository for 8.x packages
baseurl=https://artifacts.elastic.co/packages/8.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
EOF
sudo dnf install -y elasticsearch

```

Then,

`sudo vi /etc/elasticsearch/elasticsearch.yml`

```auto
cluster.name: MyCluster
node.name: mynode
path.data: /var/lib/elasticsearch
network.host: 0.0.0.0

```

Now, I attempted to browse elasticsearch website. However, I can't seem to find the username and password. I tried username like "elastic" and passowrd like 'changeme' 'elastic' 'admin' etc. But they didn't work.

Thus I decided to reset user password for elastic user.

```auto
ELASTIC_PASSWORD=$(sudo /usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic -b -s)
if [[$? -eq 0]]; then
    echo "Elastic user password: $ELASTIC_PASSWORD"
else
    echo "Failed to reset elastic user password."
    exit 1
fi

```

I try to use this script but no avail.

```auto
ERROR: Failed to determine the health of the cluster. Unexpected http status [503], with exit code 65
Failed to reset elastic user password.

```

---

<div class="post-metadata">

**Author:** ![Tortoise](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tortoise/32/147587_2.png) [@Tortoise](https://discuss.elastic.co/u/Tortoise)\
**Post date:** [December 9, 2024, 6:57am UTC](https://discuss.elastic.co/t/how-to-reset-elasticsearch-elastic-user-password/371673/2 "2024-12-09T06:57:33Z")

</div>

Hello,

Welcome!

When we install the elasticsearch it generates a random password which is shown on the screen during installation.  
If you want to reset the password we can use the reset password script, could you please confirm if the elasticsearch is running? Once it is up & running can you try to again execute the script & see what is the error?

Thanks

---

<div class="post-metadata">

**Author:** ![aalaskapedh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aalaskapedh/32/139800_2.png) [@aalaskapedh](https://discuss.elastic.co/u/aalaskapedh)\
**Post date:** [December 9, 2024, 7:25am UTC](https://discuss.elastic.co/t/how-to-reset-elasticsearch-elastic-user-password/371673/3 "2024-12-09T07:25:02Z")

</div>

Yes it's running And /var/log/elasticsearch/\*.log isn't fishy either

```auto
[root@rocky8 ~]# systemctl status elasticsearch
● elasticsearch.service - Elasticsearch
   Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2024-12-08 23:21:12 EST; 3h 3min ago
     Docs: https://www.elastic.co
 Main PID: 877 (java)
    Tasks: 81 (limit: 14920)
   Memory: 1.5G
   CGroup: /system.slice/elasticsearch.service
           ├─ 877 /usr/share/elasticsearch/jdk/bin/java -Xms4m -Xmx64m -XX:+UseSerialGC -Dcli.name=server -Dcli.script=/usr/share/ela>
           ├─1722 /usr/share/elasticsearch/jdk/bin/java -Des.networkaddress.cache.ttl=60 -Des.networkaddress.cache.negative.ttl=10 -D>
           └─1741 /usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/bin/controller

Dec 08 23:18:29 rocky8.linuxvmimages.local systemd[1]: Starting Elasticsearch...
Dec 08 23:19:08 rocky8.linuxvmimages.local systemd-entrypoint[1722]: CompileCommand: dontinline java/lang/invoke/MethodHandle.setAsTy>
Dec 08 23:19:08 rocky8.linuxvmimages.local systemd-entrypoint[1722]: CompileCommand: dontinline java/lang/invoke/MethodHandle.asTypeU>
Dec 08 23:21:12 rocky8.linuxvmimages.local systemd[1]: Started Elasticsearch.

```

I am suspecting 2GB ram, and 1 core CPU(virtual machine) isn't enough for elasticsearch. If so, I'm done with Elasticsearch as I don't have a new PC atm.

---

<div class="post-metadata">

**Author:** ![Tortoise](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tortoise/32/147587_2.png) [@Tortoise](https://discuss.elastic.co/u/Tortoise)\
**Post date:** [December 9, 2024, 7:41am UTC](https://discuss.elastic.co/t/how-to-reset-elasticsearch-elastic-user-password/371673/4 "2024-12-09T07:41:09Z")

</div>

Ok, thanks for the update.  
Please execute the curl command against this elastic node to verify if it is returning the response as expected.  
The error is clear : ERROR: Failed to determine the health of the cluster.

---

<div class="post-metadata">

**Author:** ![aalaskapedh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aalaskapedh/32/139800_2.png) [@aalaskapedh](https://discuss.elastic.co/u/aalaskapedh)\
**Post date:** [December 9, 2024, 1:17pm UTC](https://discuss.elastic.co/t/how-to-reset-elasticsearch-elastic-user-password/371673/5 "2024-12-09T13:17:15Z")

</div>

Can you provide the curl command?

```auto
curl localhost:9200 -u elastic

```

Ask for password.

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [December 9, 2024, 3:52pm UTC](https://discuss.elastic.co/t/how-to-reset-elasticsearch-elastic-user-password/371673/6 "2024-12-09T15:52:57Z")

</div>

Hi @aalaskapedh

> [@aalaskapedh](#):
>
> `877 /usr/share/elasticsearch/jdk/bin/java -Xms4m -Xmx64m`

Looks like perhaps the JVM is to 4mb to 64mb  
Elastic requires at least 512MB, perhaps 1GB

so in the

`/etc/elasticsearch/jvm.options.d/jvm.options`

Perhaps set

```auto
-Xms1g
-Xmx1g

```

or

```auto
-Xms512m
-Xmx512m

```

Also because of the way you set up your elasticsearch.yml

From the docs [here](https://www.elastic.co/guide/en/elasticsearch/reference/current/reset-password.html#_description_15)

> This command uses an HTTP connection to connect to the cluster and run the user management requests. The command automatically attempts to establish the connection over HTTPS by using the `xpack.security.http.ssl` settings in the `elasticsearch.yml`

You have set to authenticate but not SSL on HTTPS or Transport which are the defaults so in order to reset the password you need to give the non HTTPS URL

`./bin/elasticsearch-reset-password -u elastic --url http://localhost:9200`
