git commit fails with a socket error after leaving the 1Password SSH agent
error: 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.
Fix it fast
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"2Match what you see, then jump to its fix
- 1
echo $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
The variable looks fine, but ssh and git over SSH still reach for the 1Password socket.~/.ssh/config still has IdentityAgent for 1PasswordFix - 3
ssh to servers works, but only git commit fails; git commit --no-gpg-sign succeeds.Git is still set to sign commits with SSHFix
- 1
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/null2Fix
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
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/config2Fix
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 none3Verify
ssh now reaches the agent you started.
ssh-add -lConfirmed by 1password.dev
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
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
Security
ssh-agent will not start or Git cannot use your SSH key
Bad configuration option: usekeychain
ssh-add and ssh can only use the agent when SSH_AUTH_SOCK points at a running one.
4 causes, each with a fixSecurity
Entra ID token request fails: the request body must contain the parameter 'grant_type'
AADSTS900144: The request body must contain the following parameter: 'grant_type'.
The token endpoint did not find grant_type in the form body of your POST.
3 causes, each with a fixSecurity
Angular HttpClient does not add the X-XSRF-TOKEN header to a request
403 Forbidden on POST, PUT or DELETE while GET works
Angular copies the XSRF-TOKEN cookie into an X-XSRF-TOKEN header only for mutating requests to the same origin, and only when the cookie is readable by script.
5 causes, each with a fixSecurity
An [Authorize] endpoint rejects a request with a bearer token
Authorization Header sent: no Bearer token sent.
An [Authorize] endpoint without a policy name requires an authenticated user.
4 causes, each with a fixSecurity
ASP.NET Core API rejects an Angular user's token: the signature key was not found
401 Unauthorized
The API looked for the key named by the token's kid in the key set it downloaded from your Authority, and the key was not there.
4 causes, each with a fixSecurity
ASP.NET Core rejects the token before checking it: IDX12741, three segments expected
401 Unauthorized
IDX12741 means the string the API pulled out of the Authorization header is not shaped like a JWT: a signed token has three dot-separated parts and an encrypted one has five.
3 causes, each with a fix