Elasticsearch.service: Failed with result 'exit-code'

My Elasticsearch is not starting, I don't know why I am getting below error.

root@i3insight2:~# systemctl status elasticsearch.service
â elasticsearch.service - Elasticsearch
   Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Wed 2021-09-01 19:27:39 PKT; 14h ago
     Docs: http://www.elastic.co
  Process: 26386 ExecStart=/usr/share/elasticsearch/bin/elasticsearch -p ${PID_DIR}/elasticsearch.pid (code=exited, status=1/FAILURE)
 Main PID: 26386 (code=exited, status=1/FAILURE)

Sep 01 19:27:39 i3insight2 elasticsearch[26386]:         at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
Sep 01 19:27:39 i3insight2 elasticsearch[26386]:         at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
Sep 01 19:27:39 i3insight2 elasticsearch[26386]:         at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:219)
Sep 01 19:27:39 i3insight2 elasticsearch[26386]:         at java.base/java.nio.file.Files.newByteChannel(Files.java:373)
Sep 01 19:27:39 i3insight2 elasticsearch[26386]:         at java.base/java.nio.file.Files.newByteChannel(Files.java:424)
Sep 01 19:27:39 i3insight2 elasticsearch[26386]:         at java.base/java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:420)
Sep 01 19:27:39 i3insight2 elasticsearch[26386]:         at java.base/java.nio.file.Files.newInputStream(Files.java:158)
Sep 01 19:27:39 i3insight2 elasticsearch[26386]:         at org.elasticsearch.tools.launchers.JvmOptionsParser.main(JvmOptionsParser.java:61)
Sep 01 19:27:39 i3insight2 systemd[1]: elasticsearch.service: Main process exited, code=exited, status=1/FAILURE
Sep 01 19:27:39 i3insight2 systemd[1]: elasticsearch.service: Failed with result 'exit-code'.

I want to do my project in production mode. It is working perfectly underdevelopment of the project after production mode this is not working. I want my project to read data continuously without running manually. But is not working now.

Please don't post pictures of text or code. They are difficult to read, impossible to search and replicate (if it's code), and some people may not be even able to see them :slight_smile:

Dear I edited the post please do help me how to resolve this issue.

You will need to check /var/log/elasticsearch for the full log of what is happening there.

This is my log file.

root@i3insight2:/var/log/elasticsearch# tail -f elasticsearch.log
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-7.2.0.jar:7.2.0]
        at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-7.2.0.jar:7.2.0]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:115) ~[elasticsearch-7.2.0.jar:7.2.0]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~[elasticsearch-7.2.0.jar:7.2.0]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
        at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:105) ~[elasticsearch-7.2.0.jar:7.2.0]
        at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:172) ~[elasticsearch-7.2.0.jar:7.2.0]
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:349) ~[elasticsearch-7.2.0.jar:7.2.0]
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-7.2.0.jar:7.2.0]

That'd be why.
How did you install Elasticsearch?

This is installed on the server so I don't know about this much, I am just using it last 2 months, It is working fine but since yesterday It is not working. May be a permissions issue from the admin side.

That's not likely, the service file that is included in DEB/RPM installs ensures that Elasticsearch runs as the correct user.

This sounds like it is a custom install.