Cannot start elasticsearch with the root user

Have you seen that when you start the cluster it says you cannot start with the root user but then you change the /usr/share/elasticsearch and elasticsearch data directory ownership to the elasticsearch user and still the same?

you need to provide some more detail about output you getting.

I am starting elasticsearch as root and it is working

You should never ever run Elasticsearch as root and I believe this should be checked on startup if you are in production mode and fail if you are starting as root.

at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:127) ~[elasticsearch-cli-7.10.2.jar:7.10.2]
	at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-7.10.2.jar:7.10.2]
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:126) ~[elasticsearch-7.10.2.jar:7.10.2]
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~[elasticsearch-7.10.2.jar:7.10.2]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
	at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:111) ~[elasticsearch-7.10.2.jar:7.10.2]
	at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:178) ~[elasticsearch-7.10.2.jar:7.10.2]
	at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:393) ~[elasticsearch-7.10.2.jar:7.10.2]
	at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:170) ~[elasticsearch-7.10.2.jar:7.10.2]

Caused by: java.lang.RuntimeException: can not run elasticsearch as root

This error message indicates that Elasticsearch is checking whether you are running as root and refusing to start as this is the case.

This is the only box I'm seeing this error. The others are running as root and this is not happening.

Are the nodes in a cluster or running as standalone nodes? Can you show us the process listing from one of the other nodes together with the node configuration?

It looks like you are running a quite old version that is EOL. Do you have any thirdparty plugins installed that may affect this behaviour? Are there any configuration differences between the nodes?

@Christian_Dahlqvist thanks for your reply. This is a single-node cluster

let me correct my self.

I am starting up daemon as root.
but process is running as user elasticsearch

1 Like

Elasticsearch will never run as root. It has inbuilt checks to only run as a non-root user and it will refuse to run otherwise, there's no way around this.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.