E: Sub-process /usr/bin/dpkg returned an error code (1)

I was trying to uninstall elasticsearch and reinstall it. when I remove it with below command it was showing following error.

$ apt-get --purge autoremove elasticsearch

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
elasticsearch*
0 upgraded, 0 newly installed, 1 to remove and 2 not upgraded.
After this operation, 30.5 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 37152 files and directories currently installed.)
Removing elasticsearch (2.4.5) ...
Stopping elasticsearch service...Failed to issue method call: Unit elasticsearch.service not loaded.
dpkg: error processing package elasticsearch (--purge): subprocess installed pre-removal script returned error exit status 5 NOT starting on installation, please execute the following statements to configure elasticsearch service to start automatically using systemd

sudo systemctl daemon-reload
sudo systemctl enable elasticsearch.service
You can start elasticsearch service by executing

sudo systemctl start elasticsearch.service
Errors were encountered while processing:
** elasticsearch**
E: Sub-process /usr/bin/dpkg returned an error code (1)

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