487 字
2 分钟
ECONNREFUSED vscode-git.sock 简单Debug分享

1. Issue#

在一次平平无奇的git push后,我得到了这么个奇怪的反馈:

Terminal window
Missing or invalid credentials.
Error: connect ECONNREFUSED /run/user/1000/vscode-git-95caf6ea0e.sock
at PipeConnectWrap.afterConnect [as oncomplete] (node:net:1637:16) {
errno: -111,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '/run/user/1000/vscode-git-95caf6ea0e.sock'
}
remote: No anonymous write access.
fatal: Authentication failed for 'https://github.com/Asteroid77/meteor-s-blog.git/'

2. 排查过程#

其实这东西往LLM那边一扔就知道是什么问题,但想变成自己的东西还得总结一下。

观察错误:

Terminal window
Missing or invalid credentials.
Error: connect ECONNREFUSED /run/user/1000/vscode-git-95caf6ea0e.sock
at PipeConnectWrap.afterConnect [as oncomplete] (node:net:1637:16) {
errno: -111,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '/run/user/1000/vscode-git-95caf6ea0e.sock'
}
  1. Missing or invalid credentials. 说明跟Github那边的推送的时候出了凭证问题。
  2. connect ECONNREFUSED /run/user/1000/vscode-git-95caf6ea0e.sock. 说明出问题的异常是跟vscode-git.sock连接时,被ECONNREFUSED拒绝了。
  3. Linux下,/run/** 这样的目录一般是运行时目录,也就是临时目录。

推测:vscode-git.sock挂掉了,导致GitVS Code获取用户推送仓库的权限凭证时出现被拒绝,于是就出现了这个问题。

实际:Git 试图通过 Unix Domain Socket(.sock文件)与 VS Code 进行进程间通信(IPC)以获取凭证,但连接被拒绝(ECONNREFUSED)

解决方法很简单,Ctrl+Shift+P点击reload windowvscode-git.sock重启即可。

或者键入env | grep GIT查看当前环境变量

Terminal window
VSCODE_GIT_ASKPASS_NODE=/home/meteor/.vscode-server/bin/xxx/node
GIT_ASKPASS=/home/meteor/.vscode-server/bin/xxx/extensions/git/dist/askpass.sh
VSCODE_GIT_ASKPASS_EXTRA_ARGS=
VSCODE_GIT_IPC_HANDLE=/run/user/1000/vscode-git-95caf6ea0e.sock
VSCODE_GIT_ASKPASS_MAIN=/home/meteor/.vscode-server/bin/xxx/extensions/git/dist/askpass-main.js

这个时候unset GIT_ASKPASS应该就能触发Git向用户要求输入凭证。

GIT_ASKPASS 环境变量告诉 Git在推送的时候找VS Code要凭证。

当我们 unset 它之后,Git 发现没人替它干活了,就会回退到默认行为——直接在终端里弹窗或提示让你手动输入账号密码。

当然,以上都比不上reload window来的简单有效。

哪怕不认识这些,去搜索的时候也尽可能精准描述,这样获取答案会更快一些。

比如说这个问题,搜索: git ECONNREFUSED vscode-git sock比起git push failed Missing or invalid credentials in vscode在得到答案的速度和准确度上肯定要快上许多。。

ECONNREFUSED vscode-git.sock 简单Debug分享
https://blog.astro777.cfd/posts/debug/normal-debug-share/
作者
ASTRO
发布于
2026-01-08
许可协议
CC BY-NC-SA 4.0