66

I was trying to do my first push on a new MacBook and got this error after git push (everything worked well on my old MacBook):

Missing or invalid credentials.
Error: connect ECONNREFUSED /var/folders/tx/53fffl0j51qb47mhnlf8zsdc0000gn/T/vscode-git-1d38026c7f.sock
    at PipeConnectWrap.afterConnect [as oncomplete] (net.js:1056:14) {
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '/var/folders/tx/53fffl0j51qb47mhnlf8zsdc0000gn/T/vscode-git-1d38026c7f.sock'
}
Missing or invalid credentials.
Error: connect ECONNREFUSED /var/folders/tx/53fffl0j51qb47mhnlf8zsdc0000gn/T/vscode-git-1d38026c7f.sock
    at PipeConnectWrap.afterConnect [as oncomplete] (net.js:1056:14) {
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '/var/folders/tx/53fffl0j51qb47mhnlf8zsdc0000gn/T/vscode-git-1d38026c7f.sock'
}
remote: No anonymous write access.
fatal: Authentication failed for 'https://github.com/username/repo.git/'

Any idea why and how I can resolve it?

7
  • 1
    You have to set up on your new laptop the credentials to connect to github
    – Ôrel
    Jul 12, 2020 at 11:22
  • 1
    "Missing or invalid credentials" I don't want to leap to conclusions but my guess is that your credentials are missing, or perhaps invalid.
    – matt
    Jul 12, 2020 at 11:31
  • I have set up credentials by using git config user.name "your username" and git config user.password "your password", and could see these by running git config --list, what am I missing here? Jul 12, 2020 at 11:36
  • 2
    There is no such config key user.password. See the docs.
    – phd
    Jul 12, 2020 at 12:07
  • Beware if you're using an integrated VS Code terminal (to avoid this, use a normal terminal instead), the following could be the issue: stackoverflow.com/a/63302881/12298276
    – Andreas L.
    Jan 16, 2021 at 16:26

11 Answers 11

126

You are trying to use git from a terminal in vscode. The problem comes from the authentication handler of vscode. To solve the problem:

  • Open vscode File > Preferences > Settings
  • Search for git.terminalAuthentication
  • Uncheck the option

You have to re-open the terminal to make it work.

As of March 2022, the menus have changed a bit. Here's an illustration of how to access them: enter image description here

enter image description here

6
  • 3
    For my version, it's under 'vscode / preferences / settings; under the settings for my host: extensions / git / terminal authentication'
    – commonpike
    Dec 28, 2020 at 10:15
  • Here is more to read on that issue: stackoverflow.com/a/63302881/12298276
    – Andreas L.
    Jan 16, 2021 at 16:27
  • If you work with the JSON-settings file, insert the following line into it: git.terminalAuthentication: false
    – Andreas L.
    Jan 16, 2021 at 16:33
  • 6
    Try running the command from new terminal, if it was working previously and stopped, this might work. I had renamed the origin repo and created new repo with the old origin name, so that I can push my codes to an empty repo with same name as the origin. It was giving similar error so I just tried running git push -u origin [branchname] from a new terminal and it worked :) Jun 22, 2022 at 13:07
  • Nice solution!, I'm using ubuntu, I disabled that setting in vscode, but, I have to log out and log back into my system to kill git.vscode.sock, then everything works! May 12 at 17:13
33

Reloading the VSCode window (shift-control-P to open the Command Palette then find Developer: Reload Window and press Enter) fixed this for me.

2
  • 5
    Try running the command from new terminal before you try reloading the window. Jun 22, 2022 at 13:10
  • 1
    Thanks @anirudhsharma new terminal trick worked for me. Jun 23, 2022 at 17:54
26

If you're on linux, just add sudo before the command. Otherwise, you have to add administration prefix to the command.

3
  • solved my problem, but still wandering, is that any connection with python env(base)? cz i'am using vs code,,
    – Budi Mulyo
    Dec 10, 2020 at 16:25
  • i don't know, but i think it has nothing to do with python env. Dec 11, 2020 at 1:51
  • Try running the command from new terminal as it worked for me :) Jun 24, 2022 at 18:13
16

As mentioned in marpo-it's answer, the setting git.terminalAuthentication can be unchecked (since VSCode 1.45)

setting

That will avoid that, for Git commands invoked in the Integrated Terminal, like git push for instance, you would automatically be authenticated against your GitHub account.


Original answer:

I have set up credentials by using git config user.name "your username" and git config user.password "your password", and could see these by running git config --list, what am I missing here?

Those are not "credentials": they won't help authenticate you to a remote service like GitHub.

For HTTPS URLS (https://github.com/<me>/<myRepo>), you would need to:

There you would enter your actual credentials:

  • your GitHub user account name
  • your GitHub user account password (or a PAT if you have 2FA activated)

But if the issue disappear today, then this was linked to this GitHub incident.


Andreas L also mentions in the comments that trying to authenticate from an integrated VS Code terminal can be tricky.
As detailed in "git push origin master Missing or invalid credentials", and here:

If you work with the JSON-settings file, insert the following line into it:

git.terminalAuthentication: false,
11
  • 1
    Very strange, after restarting my MacBook, everything works. Jul 13, 2020 at 21:44
  • @thinkvantagedu Then this was about githubstatus.com/incidents/j597fw8kv04c
    – VonC
    Jul 13, 2020 at 21:56
  • In case of using an integrated VS Code terminal, the following could be the issue: stackoverflow.com/a/63302881/12298276. In case you would like to avoid this behavior in future, open the JSON-settings file and insert the following line into it: git.terminalAuthentication: false
    – Andreas L.
    Jan 16, 2021 at 16:37
  • @AndreasL. Thank you for this feedback. I have included your comment in the answer for more visibility.
    – VonC
    Jan 16, 2021 at 16:43
  • 1
    It was working fine for me before. This issue started without any change from my side. Unchecking the Terminal Authentication option, reloading the terminal then checking the option and reloading the terminal again fixed it for me.
    – BibekStha
    Aug 26, 2021 at 17:01
1

In my case I got the error because I was trying to push to an HTTPS remote

https://github.com/USER/REPO.git

But instead, I had to go to the repository on GitHub and copy the SSH address, which looks like this

[email protected]:USER/REPO.git

1
0

I had a similar issue. I had to modify the git config as follows:

[credential]
        helper = manager

Before it was set to wincred.

0

If You are using Windows 10. Go to control pannel and search for Windows Credential Manager. There you can find Git/bitbucket url From there You can click on edit and change your Credentials

0

This happens to me from time to time. Running vscode on win 11. I

I will get the same response Missing or invalid credentials for all interactions (clone, push, etc). I had tried various solutions without success.

I can still generate a repository password and use git clone (for example) from the command line, copying in the password when prompted. Not really ideal.

I have found the easiest & most reliable way to fix this is to reinstall Git Credential Manager Core. This is included in Git for Windows. The recommended way to install Git Credential Manager Core is just to install Git for Windows although there is also a standalone installer it seems simpler to use Git for Windows install to keep everything in line with latest. Once reinstalled my credentials are picked up again without me needing to enter them.

0

Solution: This worked for me, use "sudo git push"

➜ sudo git push

Username for 'https://github.com': tempName

Password for 'https://[email protected]':

Note: use personal access token for password.

Here you can check how to create personal access token: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens

-1

I also ran into the same error but turns out I had 2 terminals opened. I've configured everything on the older terminal, so pushing doesn't seem possible using the new VSCode terminal. It's a good idea to check if you have multiple terminals opened that have not been configured for git usage.

New contributor
theFlyingGenes is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
-2

Please do no downgrad if it does not apply to you, this answer may help people with below mentioed scenario.

Note: This answer is specific to people running Windows Subsystem for Linux with custom certificates for git server, it does not apply to people without WSL or WSL with no custom certificates

Check if your distro is running even as my git gogs certificate are stored and installed in WSL and without them, I can not push or pull.

For me, my vsCode was running in a remote disconnected state since WSL distro was shutdown or terminated so my certificates couldn't be aquired.

Restarting WSL distro solved the issue by reconnecting vsCode remote by providing access to my certificates.

1
  • I hope those people need this find this.
    – Jovylle
    Nov 23 at 4:24

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.