Git push returns error code 403 in Bitbucket Server / Data Center
Summary
When pushing to Bitbucket Server or Bitbucket Data Center, it responds with the error code 403 (Forbidden error).
$ git push url directory
Cloning into 'directory'...
error: The requested URL returned error: 403 while accessing url
fatal: HTTP request failed
Environment
Tested in Bitbucket Data Center 7.12.1
Applied to Bitbucket Data Center 7.x and 8.x
Diagnosis
- Verify the permissions for problematic users at both Global Permissions as well as Project and Repository levels.
- Verify the "Allow basic authentication on API calls" under the Authentication method.
Cause
Scenario 1: When users do not have permission to push changes to this repository.
Scenario 2: "Allow basic authentication on API calls" under the Authentication method is disabled.
Solution
Scenario 1: You have permission to see the repository, but not to contribute. You may want to review the project and repository settings.
More info on Using Project permissions and Repo permissions.
Scenario 2: Enabling the "Allow basic authentication on API calls" should resolve this issue.