ASP
ASP

Reputation: 131

Failed to start elasticsearch service

I am trying to start elasticsearch on windows.

ES 5.0.0, JDK 1.8.0.66, Windows 10

Service is installed properly but failed to start.

D:\Softwares\Elastic_Project\elasticsearch-5.0.0\bin>elasticsearch-service install
C:\Program Files\Java\jdk1.8.0_66
Installing service : "elasticsearch-service-x64"
Using JAVA_HOME (64-bit): "C:\Program Files\Java\jdk1.8.0_66"
The service 'elasticsearch-service-x64' has been installed.

D:\Softwares\Elastic_Project\elasticsearch-5.0.0\bin>elasticsearch-service start
C:\Program Files\Java\jdk1.8.0_66
Failed starting 'elasticsearch-service-x64' service

Logs

[2016-11-24 14:21:19] [info] [11120] Commons Daemon procrun (1.0.15.0 64-bit) started
[2016-11-24 14:21:20] [info] [11120] Starting service 'elasticsearch-service-x64' ...
[2016-11-24 14:21:20] [info] [11572] Commons Daemon procrun (1.0.15.0 64-bit) started
[2016-11-24 14:21:20] [info] [11572] Running 'elasticsearch-service-x64' Service...
[2016-11-24 14:21:20] [info] [ 5916] Starting service...
[2016-11-24 14:21:21] [info] [ 5916] Service started in 1487 ms.
[2016-11-24 14:21:21] [info] [11572] Run service finished.
[2016-11-24 14:21:21] [info] [11572] Commons Daemon procrun finished
[2016-11-24 14:21:23] [error] [11120] Failed to start 'elasticsearch-service-x64' service
[2016-11-24 14:21:23] [error] [11120] The data area passed to a system call is too small.
[2016-11-24 14:21:23] [info] [11120] Start service finished.
[2016-11-24 14:21:23] [error] [11120] Commons Daemon procrun failed with exit value: 5 (Failed to start service)
[2016-11-24 14:21:23] [error] [11120] The data area passed to a system call is too small.

I have added JAVA_HOME in system variable. System logs

The Elasticsearch 5.0.0 (elasticsearch-service-x64) service terminated with the following service-specific error: 
Incorrect function.

Any help ?

Upvotes: 4

Views: 16186

Answers (5)

Manikandan
Manikandan

Reputation: 894

This issue because of either wrongly set environmental variable or not set environmental variable the document Failed to start elasticsearch service explained how we set JAVA_HOME system variable and how we did mistake when set. Also the document Elastic search install as window service explained about how we install elastic search as window service as well as how it set as automatic service.

Upvotes: 0

Thomas Brooks
Thomas Brooks

Reputation: 341

I had similar error, with elasticsearch ver. 7.7.0 on Windows 10 64 bit. Service installed successfully, but failed to start with elasticsearch-service.bat start. No problem starting elasticsearch in console, but windows service failed starting. The relevant elasticsearch-service-x64 log displayed:

[2020-05-20 16:36:30] [info]  [ 4988] Starting service...
[2020-05-20 16:36:33] [error] [10428] apxServiceControl(): dwState(4) != dwCurrentState(1); dwWin32ExitCode = 1067, dwWaitHint = 0, dwServiceSpecificExitCode = 0
[2020-05-20 16:36:33] [error] [10428] apxServiceControl(): returning FALSE

It was resolved by doing the following steps:

  1. Removing the elasticsearch service (elasticsearch-service.bat remove);
  2. Installing latest Java JDK - 14.0.1 (instead of 11.0.7 which was installed on my computer);
  3. Changing the value of JAVA_HOME in system variables to the root directory of jdk-14.0.1;
  4. Restarting the computer;
  5. Verification in CMD that java -version displays the correct Java version (14.0.1);
  6. Installing elasticsearch service (elasticsearch-service.bat install);
  7. Starting elasticsearch service (elasticsearch-service.bat start) - and it started successfully.

Note: It's possible that you'll have to start the service when using the CMD as an administrator.

Upvotes: 1

shine
shine

Reputation: 678

You can check the elasticserch/logs/elasticserch.log

I fixed this by running .\elasticsearch-service manager and in the GUI, java tab, changing from -Djava.io.tmpdir= to -Djava.io.tmpdir=C:\Windows\Temp

https://github.com/elastic/windows-installers/issues/310

Upvotes: 2

Underverse
Underverse

Reputation: 1311

In Windows 7 on a system that had Java 1.7 then upgraded to Oracle Java 1.8 SDK (jdk-8u45-windows-x64.exe) the system JAVA_HOME was different to the JAVA_HOME in the elasticsearch manager and a different version of java was in the path. Also, elasticsearch-service install failed as the system was not loading Java 8.

Set the system JAVA_HOME to the correct folder:

  1. Open Windows File Explorer Super+E
  2. Right-click My Computer
  3. Select Advanced system settings
  4. Select Environment Variables
  5. Select JAVA_HOME
  6. Edit JAVA_HOME to change the value to the correct root folder e.g. C:\Progra~1\Java\jre1.8.0_45
  7. OK twice

Check that JAVA_HOME is set and java works:

  • java -version
  • echo %JAVA_HOME%

If this fails then eleasticsearch-service install won't work. To fix in a DOS prompt:

  • set JAVA_HOME=C:\Progra~1\Java\jre1.8.0_45
  • path=C:\Program Files\Java\jdk1.8.0_45\bin;%path%

Check the JAVA_PATH value in Elasticsearch manager and fix it if required. Open the manager program from a DOS prompt:

  1. Run elasticsearch-service.bat manager from a DOS prompt.
  2. Click on the Java tab
  3. Click the ... button to the right of %JAVA_HOME%\bin\server\jvm.dll
  4. Select the correct JRE folder if required or set the value manually, e.g. C:\Program Files\Java\jdk1.8.0_45\jre\bin\server\jvm.dll
  5. Click Apply
  6. Select the General tab
  7. Click Start
  8. Click OK to close the Elasticsearch manager

Removing and re-adding the elasticsearch service may be needed:

  • elasticsearch-service.bat remove
  • elasticsearch-service.bat install

Open elasticsearch in a browser using the settings in config\elasticsearch.yml to check that it is running:

http://localhost:9200/

Upvotes: 8

Yohan Chung
Yohan Chung

Reputation: 539

I had the same problem. I could find the cause of the issue by looking up the log file at e.g. ~/elasticsearch-5.2.1/log/elasticsearch-service-x64.2017-02-20. It complained about "Failed creating java %JAVA_HOME%\jre\bin\server\jvm.dll". So, I reset JAVA_HOME as system variable (not user variable) in environment variables, and it's resolved.

Upvotes: 2

Related Questions