Skip to content

Solving "Invalid Credentials" Error When Pushing to Bitbucket

Problem Overview

If you're encountering the "fatal: Invalid credentials" error when attempting to push to Bitbucket, you're experiencing a common issue that began affecting users in early 2022. The error message typically includes:

fatal: Invalid credentials
Password for 'https://username@bitbucket.org':
remote: Bitbucket Cloud recently stopped supporting account passwords for Git authentication.

This happens because Bitbucket discontinued password-based authentication for Git operations over HTTPS starting March 1, 2022. Even if your account password is correct, it will no longer work for Git authentication.

Method 1: Using App Passwords (Most Common)

App passwords are the recommended replacement for account passwords when authenticating with Git over HTTPS.

Step-by-Step Guide

  1. Create an App Password

    • Log in to your Bitbucket account
    • Navigate to App Passwords
    • Click Create app password
    • Configure permissions (at minimum, select Repositories: Read and Repositories: Write)
    • Give it a descriptive label (e.g., "Git Push Access")
    • Copy the generated password immediately - you won't be able to view it again
  2. Update Your Repository Configuration

For existing repositories:

bash
git remote set-url origin https://username:app_password@bitbucket.org/username/repo-name.git

For new repositories:

bash
git clone https://username:app_password@bitbucket.org/username/repo-name.git

WARNING

Replace username with your Bitbucket username (not email) and app_password with the generated app password.

Method 2: Update Credential Manager (Windows)

If you're using Windows, you can update your stored credentials:

  1. Open Credential Manager
  2. Navigate to Windows Credentials
  3. Find and edit your Bitbucket credentials
  4. Replace your password with the app password

Alternatively, add a new generic credential:

  • Network address: git:https://bitbucket.org
  • Username: Your Bitbucket username
  • Password: Your app password

Method 3: Configure Your IDE

If you're using an IDE like Android Studio, IntelliJ, or VS Code:

  1. Generate an app password as described above
  2. When prompted for authentication in your IDE, use:
    • Username: Your Bitbucket username
    • Password: The generated app password

TIP

For VS Code users with the Atlassian extension, you may be able to authenticate through the extension's authorization flow.

Method 4: Use SSH Authentication (Advanced)

For a more secure, passwordless approach, consider setting up SSH authentication:

  1. Generate an SSH key if you haven't already
  2. Add your public key to your Bitbucket account
  3. Change your remote URL to use SSH instead of HTTPS:
bash
git remote set-url origin git@bitbucket.org:username/repo-name.git

INFO

SSH authentication is generally more secure and doesn't require entering credentials repeatedly once set up.

Troubleshooting Common Issues

  • Username vs. Email: Ensure you're using your Bitbucket username (not email address) for authentication
  • Permissions: Verify your app password has the necessary repository permissions
  • Cached Credentials: Clear any cached credentials that might be using your old password
  • Two-Factor Authentication: App passwords work with 2FA-enabled accounts

Why This Change Was Made

Bitbucket moved to app passwords to enhance security. App passwords:

  • Provide granular control over permissions
  • Can be easily revoked without changing your main account password
  • Offer better security than using your primary account password across multiple services

Best Practices

  • Use unique app passwords for different applications/devices
  • Regularly review and revoke unused app passwords
  • Consider SSH authentication for enhanced security
  • Store app passwords securely using a password manager

By following these methods, you should be able to resolve the "Invalid credentials" error and continue working with your Bitbucket repositories seamlessly.

Quick Reference: App Password Creation
  1. Go to: https://bitbucket.org/account/settings/app-passwords/
  2. Click "Create app password"
  3. Select required permissions (Repo Read/Write minimum)
  4. Copy the generated password
  5. Use it in place of your account password

For additional help, refer to Bitbucket's official documentation on app passwords.