GitLab "HTTP Basic: Access denied": why Git rejects you, and how to fix it

By Melih Toksari, developer of MergeBell · Updated · 6 min read

Short answer

GitLab answers HTTP Basic: Access denied when Git over HTTPS sends credentials it won't take: a password where a token is required, or a token that is wrong, expired or revoked. A password fails when two-factor authentication is on, on GitLab.com since multi-factor authentication became mandatory there in April 2026, for SSO accounts, and where an administrator turned password access for Git off. Create a personal access token with read_repository to clone and pull, or write_repository to push as well, enter it as the password with any non-empty username, and clear the old credentials Git saved. A 403 after many failed attempts is a temporary ban on your IP address.

git clone, git pull or git push over HTTPS stops, and Git prints this:

remote: HTTP Basic: Access denied. If a password was provided for Git authentication, the password was incorrect or you're required to use a token instead of a password. If a token was provided, it was either incorrect, expired, or improperly scoped. See https://gitlab.com/help/topics/git/troubleshooting_git.md#error-on-git-fetch-http-basic-access-denied
fatal: Authentication failed for 'https://gitlab.com/group/project.git/'

GitLab got a username and password from Git and accepted neither. Here is what causes it in GitLab 19.5, how to fix each cause, and the errors that look like it but mean something else.

Why GitLab denies access

Git sent a password, and GitLab wants a token. A password doesn’t work for Git over HTTPS when:

  • two-factor authentication is on for your account, or enforced for you;
  • you use GitLab.com: since April 2026 it requires multi-factor authentication for every password sign-in, so a password no longer works for Git there;
  • you sign in with SSO or SAML, whose users can’t use a password for Git;
  • an administrator cleared Allow password authentication for Git over HTTP(S) on GitLab Self-Managed;
  • or the password is wrong.

Git sent a token, and GitLab can’t use it. It’s mistyped, it expired at midnight UTC on its expiry date, or it was revoked. Rotating a token revokes the old one at once, so a rotated token counts. The account that owns it can also be the problem: see still denied below.

Despite the message’s last words, a token with the wrong scope usually gets past this point and fails with a different error, listed further down.

Fix it with a token

  1. Create a personal access token: select your avatar, then Edit profile › Access › Personal access tokens, and Generate token › Legacy token. Give it a name and an expiry date, and select write_repository, or read_repository if you only clone and pull. Copy it now: GitLab shows it once.
  2. Run the Git command again. When Git asks, enter your GitLab username, and paste the token as the password.
  3. If you use a credential helper, it saves the token, and Git won’t ask again until the token stops working.

A shortcut for step 1: https://gitlab.com/-/user_settings/personal_access_tokens?name=Git&scopes=write_repository opens the form with the name and scope filled in. On your own instance, use its address.

GitLab’s docs also show the token inside the URL, as in git clone https://oauth2:<token>@gitlab.com/group/project.git. It works, but Git then keeps the token in plain text in the repository’s .git/config.

Two ways to skip tokens:

  • An OAuth credential helper. Git Credential Manager, included with Git for Windows, and git-credential-oauth sign you in through the browser, two-factor authentication included. Both work with GitLab.com without setup; GitLab Self-Managed needs a little configuration.
  • SSH. With an SSH key on your account, git@gitlab.com:group/project.git remotes use neither passwords nor tokens. GitLab’s notice about mandatory MFA calls SSH the preferred method.

Clear the old credentials

If Git fails again without asking for anything, it’s still sending the old credentials.

From the remote URL. git remote -v shows it. If it holds a token or password, as in https://oauth2:glpat-…@gitlab.com/…, set a clean one:

git remote set-url origin https://gitlab.com/group/project.git

From your credential helper. Tell it to forget what it saved for GitLab:

printf 'protocol=https\nhost=gitlab.com\n\n' | git credential reject

It works with whichever helper Git uses: Keychain on macOS, Git Credential Manager on Windows, store or cache on Linux. The next Git command asks again.

On Windows, with Git for Windows 2.46.0 or later. An empty username can cause the error even with a valid token. Put your username in the URL:

git remote set-url origin https://<USERNAME>@gitlab.com/group/project.git

Which token, which username

GitLab ignores the username for personal, project and group access tokens, but checks it for deploy tokens and CI/CD job tokens.

Token Username Can
Personal access token Any non-empty value, such as your username Clone and pull with read_repository; push with write_repository or api
Fine-grained personal access token (GitLab 19.2 and later) Any non-empty value Clone and pull with Code: Download; push with Code: Push, for projects inside its boundary
Project or group access token Any non-empty value The same scopes, limited by the role the token was given
Deploy token Its own: gitlab+deploy-token-<n>, unless you chose one Clone and pull only, with read_repository
CI/CD job token gitlab-ci-token, with $CI_JOB_TOKEN as the password Clone the projects the job may access; push only to a project with Allow Git push requests to the repository turned on

Which scopes to give a token, and why: GitLab token scopes explained.

Errors that look like it

These come after GitLab accepted your credentials, or before it checked them. Git ends most of them with The requested URL returned error: 403.

Git prints It means Fix
remote: You are not allowed to download code. The token has no scope for Git, like a read_user token. A token with read_repository, write_repository or api.
remote: You are not allowed to upload code. The token can read but not push: read_repository, or a deploy token. A token with write_repository or api.
remote: You are not allowed to push code to this project. Your role can’t push, such as Reporter. Ask for the Developer role, or fork and open a merge request.
remote: GitLab: You are not allowed to push code to protected branches on this project. The branch is protected. See not allowed to push to a protected branch.
remote: The project you were looking for could not be found or you don't have permission to view it. The path is wrong, or the token’s owner can’t see the project. Check the URL, and that the account is a member.
remote: Too many failed authentication attempts from this IP Too many failed sign-ins from your IP address: GitLab bans it for a while. Fix the credentials, then wait.

The ban counts Git and container registry sign-ins together. On GitLab.com, 300 failures in one minute from one IP address block it for 15 minutes. On GitLab Self-Managed the ban is off by default, and when an administrator turns it on, by default 10 failures in a minute block an address for an hour. While it lasts, even correct credentials get a 403, so stop the script or tool that keeps retrying first.

Still denied with a good token?

  • Your password expired. On GitLab Self-Managed, when an administrator sets or changes your password, you must change it at your next sign-in. Until you do, Git over HTTPS refuses your tokens too. Sign in to GitLab in a browser and set a new password.
  • The account is blocked. A blocked account can’t use Git with any credentials. Ask your administrator.
  • Your group enforces SSO for Git (GitLab.com). With Enforce SSO-only authentication for Git and Dependency Proxy activity for this group turned on, you need an active SSO session, on any device, before you can pull or push. Sign in through the group’s SSO in a browser, then try again.

On your phone

On gitlab.com, MergeBell signs in on GitLab’s own page; on a self-managed GitLab, it uses a personal access token with the api scope. Either way the sign-in stays on your phone, so Git on your computer needs a token of its own. When MergeBell uses a token, Settings shows its expiry date, and from a week before, the app warns in the inbox and in Settings, with New token to open GitLab’s token page with the name and the api scope filled in. How expiry, rotation and the warning emails work: GitLab token expired? How to rotate a personal access token.

Frequently asked questions

What does "HTTP Basic: Access denied" mean in GitLab?

GitLab refused the credentials Git sent over HTTPS. Either Git sent a password where GitLab requires a token, the password was wrong, or the token was wrong, expired or revoked. The rest of the message says: "If a password was provided for Git authentication, the password was incorrect or you're required to use a token instead of a password. If a token was provided, it was either incorrect, expired, or improperly scoped."

Why did my GitLab password stop working for git push?

With two-factor authentication on, GitLab never accepts your password for Git over HTTPS. On GitLab.com, multi-factor authentication has been mandatory for password sign-ins since April 2026, so a password no longer works for Git there. Use a personal access token as the password, an OAuth credential helper such as Git Credential Manager, or SSH.

Which token scope do I need for git clone and git push on GitLab?

For a personal, project or group access token, read_repository to clone and pull, and write_repository to push as well. A personal access token with the api scope covers both. A fine-grained personal access token needs the Code resource with the Download permission to clone and pull, and Push to push, with the project inside the token's boundary.

What username do I use with a GitLab access token?

For personal, project and group access tokens, any non-empty value: GitLab doesn't check it. Git for Windows 2.46.0 and later can fail with an empty one, so use your GitLab username. A deploy token needs its own username, gitlab+deploy-token-<n> unless you chose one, and a CI/CD job token uses gitlab-ci-token.

Why do I still get access denied after making a new token?

Git may still be sending the old credentials, from your credential helper or from a remote URL with the old token in it. Check git remote -v, then make the helper forget them with git credential reject. If Git shows a 403 with "Too many failed authentication attempts from this IP", your IP address is banned for a while: 15 minutes on GitLab.com. Any other 403 means GitLab accepted the token, but its scope or your role doesn't allow the action.

Sources

Checked against these pages on 31 October 2026. GitLab changes quickly — if something here no longer matches, tell us and we will fix it.

Do this from your phone with MergeBell

Free for the whole review loop: the To-Do inbox, diffs and line comments, approve and merge, pipelines with retry, and push alerts for your To-Dos. Works with gitlab.com and self-managed GitLab 16.0+.

Get MergeBell for iPhoneGet MergeBell for Android

On the App Store for iOS 26 or later and on Google Play for Android 12 or later. An independent app, not affiliated with GitLab Inc.