Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git push: Missing or invalid credentials. fatal: Authentication failed for 'https://github.com/username/repo.git'

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?

like image 436
thinkvantagedu Avatar asked Jul 12 '20 11:07

thinkvantagedu


People also ask

How do I fix fatal authentication failed for HTTPS GitHub com?

The “fatal: Authentication failed” error message Instead you need to generate a personal access token. This can be done in the application settings of your Github account. Using this token as your password should allow you to push to your remote repository via HTTPS. Use your username as usual.

How do I fix remote invalid username or password fatal authentication failed?

The “remote: invalid username or password” error informs you that you have incorrectly authenticated to a Git server. To solve this error, make sure that you have used the right username and password and that you are trying to access a Git repository using the correct URL.

How do I fix git failed to authenticate to remote?

It happens if you change your login or password of git service account (Git). You need to change it in Windows Credentials Manager too. type "Credential Manager" in Windows Search menu open it. Windows Credentials Manager->Windows Credential and under Generic Credentials edit your git password.


4 Answers

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

like image 67
marpo_it Avatar answered Oct 08 '22 03:10

marpo_it


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

like image 31
Triệu Phong Avatar answered Oct 08 '22 02:10

Triệu Phong


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:

  • use a credential helper (git config --global credential.helper osxkeychain)
  • update the credentials from the OSX Keychain

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,
like image 26
VonC Avatar answered Oct 08 '22 01:10

VonC


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

like image 34
Bryan Avatar answered Oct 08 '22 03:10

Bryan