gpg4win --gen-key fails to connect to IPC when using --homedir

Matthew Orlando maorlando at
Sun Oct 2 01:30:33 CEST 2016

Hash: SHA256
I had to do two things to solve this:

1: use absolute paths for the homedir. E.g.:
    gpg --homedir "C:\users\me\test\gpg" --gen-key

2: kill any existing GnuPG agents with task manager, and then start one
manually using the same homedir:
    gpg-agent --homedir="C:\users\me\test\gpg" --daemon

After you're done, kill the agent you started.



Tim Chase gnupg at
Tue Apr 2 17:00:08 CEST 2013

> I found a similar thread here:
> but it doesn't seem to have been resolved.  gpg4win was installed
> using the default location, and with none of the add-ons (no
> Outlook, shell, extensions, just gpg).  The same operation without
> --homedir works as expected.
> Any way to get this to work?
> Thanks,
> -tkc
> C:\work\tempgpg> gpg --homedir . --gen-key
> gpg (GnuPG) 2.0.17; Copyright (C) 2011 Free Software Foundation, Inc.
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.
> gpg: keyring `./secring.gpg' created
> gpg: keyring `./pubring.gpg' created
> Please select what kind of key you want:
>    (1) RSA and RSA (default)
>    (2) DSA and Elgamal
>    (3) DSA (sign only)
>    (4) RSA (sign only)
> Your selection? 1
> RSA keys may be between 1024 and 4096 bits long.
> What keysize do you want? (2048) 2048
> Requested keysize is 2048 bits
> Please specify how long the key should be valid.
>          0 = key does not expire
>       <n>  = key expires in n days
>       <n>w = key expires in n weeks
>       <n>m = key expires in n months
>       <n>y = key expires in n years
> Key is valid for? (0) 0
> Key does not expire at all
> Is this correct? (y/N) y
> GnuPG needs to construct a user ID to identify your key.
> Real name: Joe User
> Email address: joe at
> Comment: Test
> You selected this USER-ID:
>     "Joe User (Test) <joe at>"
> Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? o
> You need a Passphrase to protect your secret key.
> gpg: can't connect to the agent: Invalid value passed to IPC
> gpg: problem with the agent: No agent running
> gpg: can't connect to the agent: Invalid value passed to IPC
> gpg: problem with the agent: No agent running
> gpg: Key generation canceled.
> C:\work\tempgpg>gpg --version
> gpg (GnuPG) 2.0.17 (Gpg4win 2.1.0)
> libgcrypt 1.4.6
> Copyright (C) 2011 Free Software Foundation, Inc.
> [snip]
Version: GnuPG v2

More information about the Gnupg-users mailing list