GitLab "remote: HTTP Basic: Access denied" and fatal authentication failed
Codemia Knowledge Hub ·
The GitLab error remote: HTTP Basic: Access denied usually means Git tried to authenticate over HTTPS with credentials GitLab no longer accepts, or with a token that lacks the needed scope. The fix is almost always to stop using your account password and switch to a valid personal access token or to SSH.
Why GitLab rejects the password
When a remote uses an HTTPS URL like:
Git needs credentials for push, fetch, or clone. Modern GitLab setups commonly reject plain account passwords for Git over HTTPS. GitLab expects one of these instead:
- a personal access token
- another supported token type for the instance
- SSH key authentication, if you switch the remote to SSH
So although the error mentions HTTP Basic, the real problem is usually the wrong credential type, not GitLab being down.
Fix it with a personal access token
To stay on HTTPS, create a GitLab personal access token with the scopes your operation needs, then enter that token where Git asks for a password.
Check the remote first:
If it shows an HTTPS URL, the next push or fetch will use HTTP authentication. Clear the saved credential and fetch again:
When Git prompts, enter:
- your GitLab username
- the personal access token as the password
If your operating system has a credential manager, you may need to clear the old saved password there too.
Switch the remote to SSH
Many developers avoid HTTPS token prompts entirely by using SSH:
If the SSH key is correctly added to GitLab, this usually avoids the HTTP Basic error completely. SSH is often the smoother long-term option, especially on machines where you already manage keys for several repositories.
A token that used to work can still fail
A token can exist and still be rejected because:
- it expired
- it was revoked
- it lacks write access for pushes
- it lacks read access for clones or fetches
If the error appeared suddenly on a setup that used to work, check the token's status before changing anything else. This is also why embedding a token in the remote URL is a poor habit: it solves one prompt but makes token rotation and auditing harder.
Stale credentials in the credential helper
Git clients often cache old credentials aggressively, so you can create a correct token and still keep sending the old password. Check which helper is configured:
If a helper is set, remove or refresh the stale entry in that credential store. Otherwise Git may never ask for the new token.
A wrong remote URL can look like an auth error
Check for:
- wrong hostname
- wrong group or project path
- unexpected redirect from HTTP to HTTPS
- a username embedded in the URL from an old setup
Confirm the URL directly:
A correct token will not help if the remote path is wrong.
Accounts with two-factor authentication
With two-factor authentication enabled, a normal password is even less likely to work for Git over HTTPS. Token or SSH authentication is the intended path, so on such an account read "HTTP Basic: Access denied" as "use a token or SSH," not "retype the password more carefully."
Mistakes that keep the error coming back
- Using your normal GitLab password for an HTTPS remote.
- Creating a token without the scopes the operation needs.
- Leaving stale credentials in the OS credential manager or Git credential helper.
- Embedding tokens in remote URLs and forgetting they expired.
- Debugging GitLab server health before confirming the local client sends the right kind of credential.
Related reading
- GKE - How to serve HTTPS via the L7 load balancer?
- GKE Google Managed Certificate with DNS authorization
- GKE ingress controller annotations for proxy body size, buffer size and sever snippets
- GlusterFS, how to server files using http or https?
- Given a private key, is it possible to derive its public key?
- Gmail Error The SMTP server requires a secure connection or the client was not authenticated. The server response was 5.5.1 Authentication Required
- GitLab Runner Failed to register the runner. You may be having network problems
- Given a commit id, how to determine if current branch contains the commit?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseSystem Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.