[bitbucket] Authentication failed to bitbucket

I'm trying to push my project via the https protocol on bitbucket using sourcetree.
But I can't connect to bitbucket with my login and password (which work on the website), I have a fatal error : "Authentication failed".

I read on other posts I can work around the problem using the ssh protocol instead of the https one, so I set up a ssh key following instructions on the source tree faq. But now I don't know how I can change to the ssh protocol when I want to push my code. Someone know how I can do this ? Thank you.

This question is related to bitbucket atlassian-sourcetree

The answer is


In windows this worked for me

git config --global http.sslVerify false


Tools -> options -> git and selecting 'use system git' did the magic for me.


I recently had a similar issue with SourceTree: any time I tried to push/pull/fetch to/from the remote origin I would get an authentication error (using SourceTree with Stash). Sometimes I would be challenge in Stash with a CAPTCHA but it never made a difference if I provided the correct information or not.

For me, we're using SourceTree and Stash in a corporate environment; user accounts are based on network credentials. Part of our network security requires us to change those passwords on a regular basis.

I was operating under the assumption that SourceTree/Stash was "aware" of any change made to my network password. But apparently -- at least in this instance -- it was not.

To fix, all I needed to do was:

Tools > Options > Authentication > Edit (Edit Password)

I set the password to match my current network password and everything began working as expected.

Not sure if this helps the OP but I hope it may help someone else looking for answers to a similar issue.


I Reverted to sourcetree 2.0

This solved the bug for me.

https://www.sourcetreeapp.com/download-archives


Windows start up menu,Search for windows credential manager. Search for bitbucket url, Try updating password there.. and do git operation again. It should work.


OBSOLETE ANSWER - VERIFIED NOVEMBER 17, 2020


On Mac, I needed to go to Preferences > Accounts, then add a new account as Bitbucket Server and enter my company's bitbucket server URL. Then I had to choose HTTPS as the protocol and enter my username (without @email) and password.

Also I set this new account as the default account by clicking the Set Default... button in the bottom of the Preferences > Account page.


I was using below command

git clone -b branch-name https://<username>@bitbucket.org/<repository>.git

Issue got resolved after adding password with username (see below command):

git clone -b branch-name https://<username>:<password>@bitbucket.org/<repository>.git

I was trying the git push --all bitbucket call and it was throwing back the "fatal: Authentication failed for 'https://..." response. The solution that worked for me was to change the command to:

git push --all https://{username}@{url}

On Windows, this popped up a dialog that allowed me to enter my password and the push worked.


None of the above worked for me - the problem lay in my Sourcetree Preferences. In the Network tab, I had a setting there for 'Default usernames for URLs which do not include one:'. The username was incorrect where I had entered it incorrectly previously - I had set it to my email rather than username. I highlighted the entries and clicked Remove for both. Then I returned to my repository page and clicked Push again. On pushing, it asked me for full username and password, which I was able to enter correctly - the push then finally worked.


I had the same problem. You need to go and add an app password for sourcetree in your bitbucket settings. Click "Bitbucket settings" in menu, App passwords, create app password. Then go to SourceTree and edit your saved password


I had the same problem. It has something to do with a bug in Git for Windows. For me it was enough to change Git used in SourceTree to the embedded one:

Tools -> Options -> Git and click button 'Use Embedded Git'


The issue was solved for me after changing the repository password, using no special characters (!"§$%&&).

Obviously, win-credential-store and git and bitbucket's web interface use different character encodings.

complete procedure:

D:\shared\Project> cd /path/to/your/project
D:\shared\Project> git init
D:\shared\Project> git remote add origin https://bitbucket.org/USERNAME/project.git
D:\shared\Project> git-credential-winstore.exe

then

D:\shared\Project> git push
Failed to erase credential: Element not found
fatal: Authentication failed for 'https://bitbucket.org/USERNAME/project.git/'

After changing the passphrase:

D:\shared\Project> git push
Counting objects: 102, done.
Delta compression using up to 8 threads.
... etc. ...

Settings in Windows tresory:

address: git:bitbucket.org (remeber the preceding "git:")
user: USERNAME
pass: old incl!"§§$%&, new without!"§$%%&/( (your passphrase!)

I tried almost all the solution given here.

Which worked for me is I opened the GIT GUI and in that tried to Push. Which ask for the credentials, enter correct userid and password it will start working again.


For Mac Users. There was a default account set on the Source tree which does not allow me to clone the URL because my current URL was of different bitbucket account. So, It shows the invalid source path and I then click on Advance Options and found Authentication failed to your_clone_url. So, follow these steps

  1. Select Source Tree. Go to SourceTree menu -> Select Preferences.
  2. It will show Accounts window. Then Choose Accounts enter image description here

Here it will show list of your added accounts. Just click on Add button from the bottom and add your new bitbucket account details. It will list you account under Accounts tab. You can also set default account by clicking on Set Default .. button from bottom. Now all is done.


If you got authentication issues with the GIT console, you can try to switch your configuration to HTTPS and specify user & password with the following command :

https://<username>:<password>@bitbucket.org/<username>/<repo>.git

BUT CAREFUL: Coming back to this answer that I made a very long time ago, I want to give credits to @ChristopherPickslay for pointing out that the password is stored as clear text in the .git/config file.

If you want to roll with HTTPS, you can securely store your password with Git credential manager

But personnally, I now always use SSH authentification, as it seems to be a better practice, because you use a personal pair of public/private keys that will prevent your password to be stored outside. Apart from the fact you can put a passphrase on your key, and then you also need to store the password on a credential manager or ssh-agent.


  • Inside company but will held true anywhere.
    • Logout from Bitbucket ( in case you are using)
    • Login with your credential
    • Go back to console
    • Fire the same command
    • It will ask for password - Provide it.
    • You are good to go.

I got this error using Azure DevOps even though I had added a Personal Access Tokens as the example shown.

enter image description here

Solved it by running git pull -v from Sourcetree terminal and adding the Personal Access Tokens again through there.

enter image description here


This problem occurs because the password of your git account and your PC might be different. So include your user name as shown in the below example:

https://[email protected]/...

https: //[email protected]/...


After fighting with this for a long time, it looks like I found something that seems to work. I was optimizing the urls to not include the username (keep it as generic as possible), but the authentication dialog kept popping up:

enter image description here

I tried everything that came into mind, such as:

  1. Enable and disable MFA (Multi Factor Authentication)
  2. Create app passwords (again, with and without MFA enabled)

No matter what tools I used (including SourceTree), nothing worked. The server kept returning: "Create an app password"

Basically you must

  1. Use the url including the username (e.g. https://[email protected]/...)
  2. Use an app password created in bitbucket

Would be so nice if the server would have returned this in the response instead of suggesting to use an app password...


The issue for me was that I did not have an account added to Sourcetree.

Adding an account allowed me to push to my repo:

Tools > Options > Authentication > Add > Refresh OAuth Token

enter image description here


I tried everything else and found helpless but this indeed worked for me "To update your credentials, go to Control Panel -> Credential Manager -> Generic Credentials. Find the credentials related to your git account and edit them to use the updated passwords".

Above Solution found in this link: https://cmatskas.com/how-to-update-your-git-credentials-on-windows/


If you made an account using google/ other oauth, then you need to set a bitbucket password for your account first. The URL for that is : https://bitbucket.org/account/user// or look for Bitbucket settings under the menu.

Then can login from git (I tried via command line). I use the built in manager for credentials :

credential.helper=manager

Now, after I set the password on the bitbucket site (email verified too), and tried to push again, it prompted me for the password, then pushed the code.

Menu location image on bitbucket web page -> http://ctrlv.in/747291 as of May 2016.


Tools > Options > Use System Git , then select the git.exe file

enter image description here

The credentials will be required again, and the problem will be solved.


I solved the issue by editing the stored value in the OS X Keychain: I looked for "bitbucket" (as Application password) and changed the value.

Then on Sourcetree, when I tried to push, I directly had to re-enter my new password.


I got the same issue when password reset has happend for the domain. I tried almost all the steps in
(Tools > Options > Authentication). But nothing worked. At last i got below answer from atlassian community page and it worked.

The only thing that worked for me was navigating to C:\Users\USERNAME\AppData\Local\Atlassian\SourceTree and removing the passwd file

Once that file was deleted, I just did a "Push" and it finally asked for my password

https://community.atlassian.com/t5/SourceTree-questions/How-to-update-HTTP-S-credentials-in-sourcetree/qaq-p/297564

https://community.atlassian.com/t5/Sourcetree-questions/Getting-quot-fatal-Authentication-failed-for-quot-error/qaq-p/624663