gpg: can't connect to the agent: IPC connect call failed

I am having a problem while trying to decrypt some keys using GPG. The following output is given to me:

gpg: can't connect to the agent: IPC connect call failed

I already edited some files, pointed in this tutorial: https://michaelheap.com/gpg-cant-connect-to-the-agent-ipc-connect-call-failed/ but with no success.

Possible reasons for that?

Thanks in advance


Solution 1:

Even I had the above issue in Ubuntu 20 WSL, I tried all the below | above suggestions, but none worked for me.

root@7400-9888K13:/mnt/c/Users/PKammari# wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo apt-key add -
gpg: can't connect to the agent: IPC connect call failed

What did I do to resolve the issue?

  • remove gpg
  • install other version of gpg.

How do I do it?
apt remove gpg ( follow the instructions)
apt install gnupg1 (follow the instructions)

Option 2. sudo apt update --y

`sudo apt remove gpg`

`sudo apt-get update -y`

`sudo apt-get install -y gnupg1` 

Proof. (refer to the screenshot):
enter image description here

Solution 2:

There is probably already a gpg-agent running on the system, which your gpg command is unable to connect to.

If you do a pkill -9 gpg-agent and then source <(gpg-agent --daemon) to restart the agent, you should be able to connect to the pinentry-curses for inputting your password.

Solution 3:

To hopefully add to preetam's excellent answer above for those very new to this.

To install gnupg1 - if you get the error "Package gnupg1 is not available, but referenced....."

sudo apt remove gpg
sudo apt-get update -y
sudo apt-get install -y gnupg1