Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Security and hardening

git commit fails with a socket error after leaving the 1Password SSH agent

Errorerror: Could not connect to socket. Is the agent running?

Short answer

Something still points at the 1Password agent socket, which no longer exists. The usual places are an exported SSH_AUTH_SOCK in a shell profile, an IdentityAgent line in ~/.ssh/config, and SSH commit signing in git config. Find which one, remove it, or point it at the agent you use now.

  • Applies to macOS 15 and 26, Git 2.4x, OpenSSH 9, 1Password 8
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Print where your shell says the agent lives, and whether that path exists. A path under 2BUA8C4S2C.com.1password with no file behind it is the old agent.

    echo $SSH_AUTH_SOCK
    ls -l "$SSH_AUTH_SOCK"
  2. 2Match what you see, then jump to its fix

    1. 1echo $SSH_AUTH_SOCK prints a path ending in agent.sock inside the 1Password folder, and ls says no such file.SSH_AUTH_SOCK still exports the 1Password socketFix
    2. 2The variable looks fine, but ssh and git over SSH still reach for the 1Password socket.~/.ssh/config still has IdentityAgent for 1PasswordFix
    3. 3ssh to servers works, but only git commit fails; git commit --no-gpg-sign succeeds.Git is still set to sign commits with SSHFix

What does the error look like?

  • error: Could not connect to socket. Is the agent running?
  • fatal: failed to write commit object

Cause 1 of 3

SSH_AUTH_SOCK still exports the 1Password socket

1Check

1Password's guide offers exporting SSH_AUTH_SOCK as a way to use its agent. Search your shell startup files for that line.

grep -n "SSH_AUTH_SOCK\|1password" ~/.zshrc ~/.zprofile ~/.bash_profile ~/.bashrc 2>/dev/null

2Fix

Delete the export, open a new terminal, and start the agent you want now. ssh-agent stores its own socket path in this variable.

unset SSH_AUTH_SOCK
eval `ssh-agent -s`

3Verify

The variable now points at a socket that exists.

ls -l "$SSH_AUTH_SOCK"

Confirmed by 1password.dev

Did this fix it?

Cause 2 of 3

~/.ssh/config still has IdentityAgent for 1Password

1Check

The 1Password setup writes an IdentityAgent line, often under Host *.

grep -n -B2 IdentityAgent ~/.ssh/config

2Fix

Remove the line. To keep the 1Password agent for some hosts only, put the line under those hosts and use IdentityAgent none for the rest.

Host *
    IdentityAgent none

3Verify

ssh now reaches the agent you started.

ssh-add -l

Confirmed by 1password.dev

Did this fix it?

Cause 3 of 3

Git is still set to sign commits with SSH

1Check

With gpg.format set to ssh, git signs with ssh-keygen by default, and signing needs a key it can reach. A leftover signing setup from the 1Password days is the usual cause.

git config --list --show-origin | grep -iE 'gpg|signingkey'

2Fix

Either turn signing off, or keep it and make sure the agent in SSH_AUTH_SOCK holds the signing key (ssh-add).

git config --global commit.gpgsign false
# one-off: git commit --no-gpg-sign -m "message"

3Verify

Commit again.

git commit -m "your message"

Confirmed by git-scm.com

Did this fix it?

How do I stop it coming back?

  • When you stop using an agent, search for its socket path in shell files and ~/.ssh/config the same day.
  • Keep signing settings in one scope, so global and repository values do not disagree.
  • If you keep 1Password's agent, keep the app running in the menu bar so the socket exists.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.