gpg: can't connect to the agent: IPC connect call failed
gpg could not reach gpg-agent over its socket. Restart the agent with gpgconf, check the home folder's path and permissions, and move WSL 1 to WSL 2.
A post about this problem was printed at this address on . The text below is new, written on 2026-11-25 from the official documentation linked in it.
On this page
Try this first. It stops a stuck agent and starts a new one:
gpgconf --kill gpg-agent
gpg-connect-agent /byeIf the second command prints nothing, the agent answered and gpg will work again. If it repeats the message, the agent cannot create or use its socket, and one of the causes below applies.
Since version 2.1 only gpg-agent has control over the private keys, so every operation with a secret key goes through it. The manual says that the agent is started on demand and that there's no reason to start it by hand. "IPC connect call failed" means that gpg found or started an agent and the connection to its Unix socket did not work.
Where the socket is
Ask GnuPG instead of guessing:
gpgconf --list-dirs agent-socket
ls -l "$(gpgconf --list-dirs agent-socket)"A leftover socket file from a crashed agent can be removed once the agent is stopped. A new one is created at the next use.
Cause 1: WSL 1
The page that used to be here was about Ubuntu 20.04 on the Windows Subsystem for Linux, and its advice was to install the old gnupg1. A better answer exists. WSL 1 translates Linux system calls, while WSL 2 runs a Linux kernel with full system call compatibility. Look which one you have, in PowerShell:
wsl -l -v
wsl --set-version Ubuntu 2The second line converts the distribution named Ubuntu. Make a copy first with wsl --export. If you have to stay on WSL 1, gnupg1 still works for checking signatures, because it has no agent. It's the version 1 program, so keep secret keys out of it if you can.
Cause 2: the path is too long, or on a file system without sockets
A Unix socket address holds a path of 108 bytes on Linux, according to unix(7). A temporary GNUPGHOME deep inside a build folder goes over that. Folders shared from Windows or mounted over a network may not support sockets at all. Use a short folder on a local disk:
export GNUPGHOME="$(mktemp -d)"
chmod 700 "$GNUPGHOME"
gpgconf --kill gpg-agent
gpg --batch --list-keys
rm -r "$GNUPGHOME"All it prints is that it created a keybox and a trust database, which proves that gpg itself is fine outside the usual folder.
Cause 3: permissions and sudo
The home folder must belong to you and be closed to others. Files owned by root after a sudo gpg are the usual trap:
ls -ld ~/.gnupg
sudo chown -R "$USER" ~/.gnupg
chmod 700 ~/.gnupgWith sudo, decide whose keys you mean: sudo -H gpg uses root's folder, and plain gpg uses yours. Mixing the two leaves an agent for one user and files of the other.
Cause 4: no terminal for the passphrase
Once the connection works, the next error may be "Inappropriate ioctl for device". The agent wants to ask for the passphrase and does not know on which terminal. The manual asks for these two lines in your shell's start file:
GPG_TTY=$(tty)
export GPG_TTYIn a script without a terminal there is nobody to ask. Use --batch with --pinentry-mode loopback and a passphrase file that only the script's user can read, or a key without a passphrase that is used for nothing else.
In containers
Build images often run as a user without a home folder. Set GNUPGHOME to a folder that exists, mode 700, and remove it in the same step, as in the block above. More shell fixes are under Linux.
Same subject
Increase the maximum number of open files on Ubuntu (ulimit -n)
For a service such as nginx or PHP-FPM set LimitNOFILE in a systemd drop-in. The limits.conf file only changes login sessions, which is why edits seem ignored.
Can't install a Let's Encrypt certificate through Plesk after an update
When Plesk cannot reach Let's Encrypt after an update (cURL error 6, could not resolve host), restart its own services, then check DNS and the API host name.
PHPSolvedThe fix first, then the reason