I am trying to reinstall the elasticsearch same version on ubuntu 20.04 but I am getting the below error again and again. I have tried almost all the solution given on google but the error was not resolved. Previously same version was running fine. Then I thought to upgrade it to 8.9 but I started getting the same error in reinstalling the elasticsearch after removing it.
sudo apt-get install elasticsearch
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/318 MB of archives.
After this operation, 531 MB of additional disk space will be used.
(Reading database ... 404439 files and directories currently installed.)
Preparing to unpack .../elasticsearch_7.17.12_amd64.deb ...
dpkg: error processing archive /var/cache/apt/archives/elasticsearch_7.17.12_amd64.deb (--unpack):
new elasticsearch package pre-installation script subprocess returned error exit status 1
Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)
Please help me out to resolve it.