gitgithubvisual-studio-codeeconnrefused

git push returns Missing or invalid credentials. code: 'ECONNREFUSED', remote: Repository not found


I was able to push to 'myrepo' from my terminal without any issues until recently. Now, I am getting this -

Missing or invalid credentials.
Error: connect ECONNREFUSED /run/user/4714/vscode-git-b650b12c34.sock
    at PipeConnectWrap.afterConnect [as oncomplete] (net.js:1146:16) {
  errno: -111,
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '/run/user/4714/vscode-git-b650b12c34.sock'
}
Missing or invalid credentials.
Error: connect ECONNREFUSED /run/user/4714/vscode-git-b650b12c34.sock
    at PipeConnectWrap.afterConnect [as oncomplete] (net.js:1146:16) {
  errno: -111,
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '/run/user/4714/vscode-git-b650b12c34.sock'
}
remote: Repository not found.
fatal: Authentication failed for 'https://github.com/me/myrepo'

'myrepo' is a private repo and I am a collaborator. The repository exists and my gitconfig is set properly. This error has appeared all of a sudden.

I was using integrated VS Code terminal but this same error appears when I use my desktop terminal too.

I have tried all fixes here including setting git.terminalAuthentication: false. However as I mentioned, I am getting this error outside VS Code too.

Can anyone please help me solve this issue. Thanks!


Solution

  • As @greg-449 mentioned in the comments, the answer here fixes my problem. Password-authentication is being replaced with token-based authentication.

    Citing @Kusal Shrestha answer from the above link -

    1. Generate a new token from git dev settings.

    2. Remove and readd origin locally git remote remove origin

    3. git remote add origin https://<token>@<git_url>.git

    4. pull once: git pull https://<token>@<git_url>.git