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

**URL:** <https://discuss.elastic.co/t/e-sub-process-usr-bin-dpkg-returned-an-error-code-1/116380>\
**Category:** Elasticsearch\
**Created:** [January 21, 2018, 11:02am UTC](https://discuss.elastic.co/t/e-sub-process-usr-bin-dpkg-returned-an-error-code-1/116380 "2018-01-21T11:02:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ali\_znzd](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@Ali\_znzd](https://discuss.elastic.co/u/Ali_znzd)\
**Post date:** [January 21, 2018, 11:02am UTC](https://discuss.elastic.co/t/e-sub-process-usr-bin-dpkg-returned-an-error-code-1/116380/1 "2018-01-21T11:02:21Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 18, 2018, 11:02am UTC](https://discuss.elastic.co/t/e-sub-process-usr-bin-dpkg-returned-an-error-code-1/116380/2 "2018-02-18T11:02:30Z")

</div>

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