[git] Git push results in "Authentication Failed"

I have been using Github for a little while and I have been fine with git add, git commit, and git push so far with no problems. Suddenly I am having an error that says:

fatal: Authentication Failed

In the terminal I cloned a repository, worked on a file and then I used git add to add the file to the commit log and when I did git commit, it worked fine. Finally, git push asks for username and password. I put those in correctly and every time I do this, it says the same error.

Does anyone have any idea what the cause of this problem is and how I can fix it?

The contents of .git/config are:

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        url = http://www.github.com/######/Random-Python-Tests
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master
[user]
        name = #####
        email = ############

This question is related to git authentication github

The answer is


I'm not really sure what I did to get this error, but doing:

git remote set-url origin https://...

didn't work for me. However:

git remote set-url origin [email protected]:user/repo

somehow worked.


I was adding to Bitbucket linked with Git and had to remove the stored keys, as this was causing the fatal error.

To resolve, I opened the command prompt and ran

 rundll32.exe keymgr.dll, KRShowKeyMgr

I removed the key that was responsible for signing in and next time I pushed the files to the repo, I was prompted for credentials and entered the correct ones, resulting in a successful push.


This the way, I resolved my access denied problem in GIT GUI and git bash. SSH KEy

This SSH key is copy-pasted in the GitHub access token.Access Token

For me everything was fine, I also tried the Windows Credentials Manager but then also the problem was not resolved. Then suddenly, I got pop up from the firewall, which was the main culprit behind all. After I clicked on allow manually then I could fetch or push to GitHub.


Hi, I was getting the same error i tried all the solutions whichever mentioned in this page, but didn't work. Finally, i found the solution, So thought of posting it. Please correct me if i am wrong anywhere. These kinds of error comes if sometimes your system password has changed recently anytime. It will try to validate from old password. So, Follow these steps:

  1. Go to control panel
  2. Click on User accounts
  3. Under Credentials manager
  4. Go to Manage windows credentials
  5. Go to Generic credentials
  6. Expand git server tab
  7. click on Remove from vault

    • Also you can click edit and change your password stored here directly.

Try the following steps to Edit or Remove the saved credentials:

  1. Click Start
  2. Type: Credential Manager (On Windows 10, this is under "Start->Settings". Then search for "Credential Manager")
  3. See the Windows Credentials Manager shortcut and double-click it to open the application.
  4. Once the app is open, click on the Windows Credentials tab.
  5. Locate the credentials that you want to remove/update, they will start with "git:" and might begin with "ada:"
  6. Click on the credential entry, it will open a details view of the entry.
  7. Click Edit or Remove as required and confirm.
  8. Wash, rinse, repeat as necessary.

enter image description here


Problem Statement: "git fatal authentication failed". I am using bitbucket.

Solution: I simply deleted the user from using access management of bitbucket and then added the same user. The .gitconfig file is simple

[user]
    name = BlaBla
    email = [email protected]

[push]
    default = simple

Just to chime in here, what fixed the issue for me was I simply canceled out of the initial prompt, the ssh one opened up with my bitbucket account, I entered the password there and everything worked as expected.


Make sure that your ssh key is added to your current ssh session.

  1. Copy the output of cat ~/.ssh/id_rsa.pub to your GitHub settings under SSH and GPG keys.

  2. Update your current ssh session with ssh-add ~/.ssh/id_rsa.pub

I am using Windows Powershell with Openssh installed.


I think that for some reason GitHub is expecting the URL to NOT have subdomain www. When I use (for example)

git remote set-url origin https://www.github.com/name/repo.git

it gives the following messages:

remote: Anonymous access to name/repo.git denied
fatal: Authentication failed for https://www.github.com/name/repo.git

However, if I use

git remote set-url origin https://github.com/name/repo.git

it works perfectly fine. Doesn't make too much sense to me... but I guess remember not to put www in the remote URL for GitHub repositories.

Also notice the clone URLs provided on the GitHub repository webpage doesn't include the www.


I had the same problem. I set url in that way:

git remote set-url origin https://github.com/zkirkland/Random-Python-Tests.git

I also removed from config file this entry: askpass = /bin/echo. Then "git push" asked me for username and password and this time it worked.


If you have enabled the two-factor authentication on your Github account, then sign in to your GitHub account and go to: https://github.com/settings/tokens/new to generate new access token, copy that token and paste as a password for authentication in terminal.


This happened to us after forcing "Two Factor Authentication" before login from Gitlab. We had to paste the text inside id_rsa.pub to Gitlab, and then reintroduce the repository in VS code using the terminal.



Basically my credential was expired, and I was facing above issue.

Following 2 command helped me:

git config --global --unset credential.helper

git config credential.helper store

It will asks you for credentials next time when you try to push.

Follow below guidelines for more details for secured and unsecured storage of user name and passwords:

https://git-scm.com/docs/git-credential-store

https://git-scm.com/docs/git-credential-cache


For me, I forgot that I had changed the password on Github.com, and my keychain for shell authentication never updated to that new password. Deleting everything git from my keychain and then re-running the git request helped solve the issue, prompting me again for the new password.


In case this is tangentially helpful, since this question is now a top hit for http authentication problems with git: Windows Credential Manager had stored my password correctly, and since I was using Git LFS I configured an http URL instead of the usual ssh://.

My problem was that my corporate password policy forced an account password change but I never updated my stored credentials (since I always use an ssh key).

Simply updating the password directly in the Wincred GUI worked: just look for a git:https://<your-url> entry.


May you have changed password recently for you git account You could try the git push with -u option

git push -u origin branch_name_that_you_want_to_push

After executing above command it will ask for password provide your updated password

Hope it may help you


This worked for me, and it also remembers my credentials:

  1. Run gitbash

  2. Point to the repo directory

  3. Run git config --global credential.helper wincred


In my case, I recently changed my windows password and I have SSH key configured for git related actions (pull, push, fetch etc.,), after I encountered the "fatal: Authentication failed" error, I updated my password in the windows credential manager (Control Panel\User Accounts\Credential Manager)for all items starting with git:..., and tried again, worked this time!


If you found authentication error problem when you entered correct password and username it's git problem. To solves this problem when you are installing the git in your machine uncheck the enable git credential managerenter image description here


in Android studio canary build 3.1+, if you are using Android studio git tool, than you can use following :

  • Click on Android Studio
  • Click on Preferences...
  • GO in VersionControl -> Github
  • Here Change Auth type to Password
  • This step will require you to enter login and password. Enter you github user name a s login and github password as password.
  • Click on Test Button.

If connection is successful , than you are done and you can use android studio github UI client.


First, you can make sure to use the proper url:

git remote set-url origin https://github.com/zkirkland/Random-Python-Tests.git

Then, if it was working before, and if it wasn't asking for you username, it must be because you had stored your credentials (login/password) in a $HOME/.netrc file, as explained here. You can double-check those settings, and make sure that your proxy, if you have one, hasn't changed.

If that still doesn't work, you can switch to an ssh url:

git remote set-url origin [email protected]:zkirkland/Random-Python-Tests.git

But that means you have published your ssh public key in your Account settings.


Make sure you have WRITE permission to push.

read ***write*** admin 

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.


I also ran into the error (that's why I am landed here), but none of the suggestions worked for me. This was my very first time I try to deploy local Git to azure. When I got this error, I reset my credentials (by clicking the link in Azure) after a few tries. The problem is that at this point it tells me my user name is already taken, so I also changed my user name to another one. In the end, I manually deleted the .git folder on my local drive, and redeployed it without problem.


with correct credentials if the problem prevails

if your using androidstudio 2.1 beta then its bug , upgrade to beta 2 (3 mb update file) , this worked for me


If you are using ssh and cloned with https this will not work. Clone with ssh and then push and pulls should work as expected!


I tried the token verification method and got it to work ~3 times and wasted around 2 hours of time for that. For some reason it does not work very well for our company.

My solution was to change the authentication method from HTTPS to SSH. Here is a Github guide (https://help.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent).

After you have created the SSH key, remember to change the SSH address origin:

git remote add origin [email protected]:user/repo.git

If you are on windows and trying to push to a windows server which has domain users working as repository users (TFS), try getting into TFS URL (i.e. http:\\tfs) with IE. enter your domain account credentials and let the page appear.

CAUTION only use INTERNET EXPLORER! other browsers wont change your system credentials.

Now go to git bash and change your remote user for the repository like below :

git config user.name "domainName\userName"

And done, now you can push!


I've ran into "$ git fetch fatal: Authentication failed for 'http://...." after my windows password has expired and was changed. Multiple fetches, reboot and even reinstall of git with windows credential manager didn't help.

Surprisingly the right answer somewhere here in comments but not in answers (and some of them are really weird!). You need to go to Control panel -> Credential Manager / Windows Credentials and update you password for git:http://yourrepoaddress


I was facing the same issue on windows. Most of the time I normally face the issue due to using multiple git accounts. If you are on windows, please do open the terminal as an administrator and try running the commands again. Make sure that you have the administrator access rights.


Before you try everything above, try to git push again, yes it works on me.


Examples related to git

Does the target directory for a git clone have to match the repo name? Git fatal: protocol 'https' is not supported Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) git clone: Authentication failed for <URL> destination path already exists and is not an empty directory SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443 GitLab remote: HTTP Basic: Access denied and fatal Authentication How can I switch to another branch in git? VS 2017 Git Local Commit DB.lock error on every commit How to remove an unpushed outgoing commit in Visual Studio?

Examples related to authentication

Set cookies for cross origin requests How Spring Security Filter Chain works What are the main differences between JWT and OAuth authentication? http post - how to send Authorization header? ASP.NET Core Web API Authentication Token based authentication in Web API without any user interface Custom Authentication in ASP.Net-Core Basic Authentication Using JavaScript Adding ASP.NET MVC5 Identity Authentication to an existing project LDAP: error code 49 - 80090308: LdapErr: DSID-0C0903A9, comment: AcceptSecurityContext error, data 52e, v1db1

Examples related to github

Does the target directory for a git clone have to match the repo name? Issue in installing php7.2-mcrypt How can I switch to another branch in git? How to draw checkbox or tick mark in GitHub Markdown table? How to add a new project to Github using VS Code git clone error: RPC failed; curl 56 OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054 How to add empty spaces into MD markdown readme on GitHub? key_load_public: invalid format git - remote add origin vs remote set-url origin Cloning specific branch