[git] Pushing to Git returning Error Code 403 fatal: HTTP request failed

I was able to clone a copy of this repo over HTTPS authenticated. I've made some commits and want to push back out to the GitHub server. Using Cygwin on Windows 7 x64.

C:\cygwin\home\XPherior\Code\lunch_call>git push
Password:
error: The requested URL returned error: 403 while accessing https://MichaelDrog
[email protected]/derekerdmann/lunch_call.git/info/refs

fatal: HTTP request failed

Also set it up with verbose mode. I'm still pretty baffled.

C:\cygwin\home\XPherior\Code\lunch_call>set GIT_CURL_VERBOSE=1

C:\cygwin\home\XPherior\Code\lunch_call>git push
Password:
* Couldn't find host github.com in the _netrc file; using defaults
* About to connect() to github.com port 443 (#0)
*   Trying 207.97.227.239... * 0x23cb740 is at send pipe head!
* Connected to github.com (207.97.227.239) port 443 (#0)
* successfully set certificate verify locations:
*   CAfile: C:\Program Files (x86)\Git/bin/curl-ca-bundle.crt
  CApath: none
* SSL connection using AES256-SHA
* Server certificate:
*        subject: 2.5.4.15=Private Organization; 1.3.6.1.4.1.311.60.2.1.3=US; 1.
3.6.1.4.1.311.60.2.1.2=California; serialNumber=C3268102; C=US; ST=California; L
=San Francisco; O=GitHub, Inc.; CN=github.com
*        start date: 2011-05-27 00:00:00 GMT
*        expire date: 2013-07-29 12:00:00 GMT
*        subjectAltName: github.com matched
*        issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert High Ass
urance EV CA-1
*        SSL certificate verify ok.
> GET /derekerdmann/lunch_call.git/info/refs?service=git-receive-pack HTTP/1.1
User-Agent: git/1.7.4.3282.g844cb
Host: github.com
Accept: */*
Pragma: no-cache

< HTTP/1.1 401 Authorization Required
< Server: nginx/1.0.4
< Date: Thu, 15 Sep 2011 22:44:41 GMT
< Content-Type: text/plain
< Connection: keep-alive
< Content-Length: 55
< WWW-Authenticate: Basic realm="GitHub"
<
* Ignoring the response-body
* Expire cleared
* Connection #0 to host github.com left intact
* Issue another request to this URL: 'https://[email protected]/dereker
dmann/lunch_call.git/info/refs?service=git-receive-pack'
* Couldn't find host github.com in the _netrc file; using defaults
* Re-using existing connection! (#0) with host github.com
* Connected to github.com (207.97.227.239) port 443 (#0)
* 0x23cb740 is at send pipe head!
* Server auth using Basic with user 'MichaelDrogalis'
> GET /derekerdmann/lunch_call.git/info/refs?service=git-receive-pack HTTP/1.1
Authorization: Basic XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
User-Agent: git/1.7.4.3282.g844cb
Host: github.com
Accept: */*
Pragma: no-cache

< HTTP/1.1 401 Authorization Required
< Server: nginx/1.0.4
< Date: Thu, 15 Sep 2011 22:44:41 GMT
< Content-Type: text/plain
< Connection: keep-alive
< Content-Length: 55
* Authentication problem. Ignoring this.
< WWW-Authenticate: Basic realm="GitHub"
* The requested URL returned error: 401
* Closing connection #0
* Couldn't find host github.com in the _netrc file; using defaults
* About to connect() to github.com port 443 (#0)
*   Trying 207.97.227.239... * 0x23cb740 is at send pipe head!
* Connected to github.com (207.97.227.239) port 443 (#0)
* successfully set certificate verify locations:
*   CAfile: C:\Program Files (x86)\Git/bin/curl-ca-bundle.crt
  CApath: none
* SSL re-using session ID
* SSL connection using AES256-SHA
* old SSL session ID is stale, removing
* Server certificate:
*        subject: 2.5.4.15=Private Organization; 1.3.6.1.4.1.311.60.2.1.3=US; 1.
3.6.1.4.1.311.60.2.1.2=California; serialNumber=C3268102; C=US; ST=California; L
=San Francisco; O=GitHub, Inc.; CN=github.com
*        start date: 2011-05-27 00:00:00 GMT
*        expire date: 2013-07-29 12:00:00 GMT
*        subjectAltName: github.com matched
*        issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert High Ass
urance EV CA-1
*        SSL certificate verify ok.
* Server auth using Basic with user 'MichaelDrogalis'
> GET /derekerdmann/lunch_call.git/info/refs HTTP/1.1
Authorization: Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
User-Agent: git/1.7.4.3282.g844cb
Host: github.com
Accept: */*
Pragma: no-cache

* The requested URL returned error: 403
* Expire cleared
* Closing connection #0
error: The requested URL returned error: 403 while accessing https://MichaelDrog
[email protected]/derekerdmann/lunch_call.git/info/refs

fatal: HTTP request failed

These are the versions of git and curl that I have:

C:\Users\XPherior>git --version
git version 1.7.4.msysgit.0

C:\Users\XPherior>curl --version
curl 7.21.7 (amd64-pc-win32) libcurl/7.21.7 OpenSSL/0.9.8r zlib/1.2.5
Protocols: dict file ftp ftps gopher http https imap imaps ldap pop3 pop3s rtsp
smtp smtps telnet tftp
Features: AsynchDNS GSS-Negotiate Largefile NTLM SSL SSPI libz

This question is related to git github dvcs

The answer is


Add the user name as part of the URL and This error happens because the git command is hitting http instead of https. So set the url

git remote set-url origin https://<username>@github.com/Path_to_repo.git

After which you will be prompted for password:


change it from

url=https://[email protected]/derekerdmann/lunch_call.git 

to

url=ssh://[email protected]/derekerdmann/lunch_call.git

It works!

Do not forget the "git" before the "@".


If All else fails. Just make sure you didn't Archive your project. That was my problem, puts the whole solution in a read only mode.


I faced the same error and the cause was stupid - I did not have privileges to commit to selected repository. I did not know that I have to

  1. fork selected project first
  2. clone repository locally
  3. commit my changes locally
  4. push changes to my github clone
  5. request pull request to upstream

as described in https://help.github.com/categories/63/articles


In my case, the error was caused because I have no permissions in the repository.


I actually had a very simple fix to this. All i did was edit the git config file differently after cloning the repository. The remote origin url is what you need to edit in your default config file. It should look like seen below

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = https://*username*@github.com/*username*/*repository*.git
[branch "master"]
    remote = origin
    merge = refs/heads/master

If you are using windows, sometimes this may happen because Windows stores credentials for outer repo (in our case github) in its own storage. And credentials that saved there can be different from those you need right now.

enter image description here

So to avoid this problem, just find github in this storage and delete saved credentials. After this, while pushing git will request your credentials and will allow you to push.


Edit .git/config file under your repo directory

Find url= entry under section [remote "origin"]

Change it from url=https://github.com/rootux/ms-Dropdown.git to https://[email protected]/rootux/ms-Dropdown.git

where USERNAME is your github user name

=> This solution worked for me.


I figured out my own variation of this problem.

The issue was not changing the protocol from https to ssl, but instead, setting the Github global username and email! (I was trying to push to a private repository.

git config --global user.email "[email protected]"

git config --global user.name "Your full name"

make sure you have enough permissions to push to the repository if you do then try running these commands

git config --global user.email youremail@domain.
git config --global user.name username
git config --global user.password yourpassword

hope this helps someone


It could be an accounting issue. The Github account of the upstream (private) repo owner may not be financial. I've seen this where the client's credit card expired.


I tried every answer but without success. The following solution helped me. If you don't have write access on the repository or getting a fatal 403 error, you can solve this easily by forking the cloned project, creating a new branch and pushing that branch to your repository. You will be able to make a pull request on the cloned project and let the person that has the write permission to do the merge.


Edit .git/config file under your repo directory

Find url= entry under section [remote "origin"]

Change it from url=https://github.com/rootux/ms-Dropdown.git to https://[email protected]/rootux/ms-Dropdown.git

where USERNAME is your github user name


What worked for me was to reset the BitBucket password on the portal and then trying to push again.


Try to create your origin using SSH key instead of HTTP.

If you can initiate using SSH key then URL starts with:

[email protected]:<YOUR REPO URL>

Now you can add, commit & Push to your corresponding Branch


What worked for me:

My repo was a fork and still linked to the the parents repo.

git remote -v

Will tell you if it is your repo or not.

git remote set-url origin https://github.com/USERNAME/OTHERREPOSITORY.git

Allows you to reconfigure it to your repo and then allow you to push.


On more reason could be e-mail verification on github.com

Just log in to github.com and check if there is no message for you, to confirm your e-mail address. Confirm, if necessary.


If you are using BitBucket your account can be put into read only mode for the following reasons:

  • We are upgrading our storage segments and cannot accept new data.
  • We are rolling out changes that require no new writes.
  • The owner of the repository needs to upgrade their account to accept a higher number of users.

https://confluence.atlassian.com/display/BITBUCKET/Repositories+in+Read-Only+Mode


  1. Check if you are on the correct branch git status
  2. Check your repository permissions (write permission is needed)

A 403 code is "Forbidden". The server saw your request and refused it. Do you have permission to push to that repository?



Below is the solution

For Windows you can find the keys here:

control panel > user accounts > credential manager > Windows credentials > Generic credentials

Next, remove the Github keys.

In mac

1-In Finder, search for the Keychain Access app.

2In Keychain Access, search for github.com.

3-Find the "internet password" entry for github.com.

4-Edit or delete the entry accordingly.


I had the same issue with this same error telling me this

remote: Permission to user/repo.git denied to user2.

The problem with this is that on Windows and Mac, it's stored in cache a key path to Github.

To fix this on Mac just do this

git credential-osxkeychain erase

Nothing will prompt at the console.

Then just do a normal push and it should let you write your username and password again from Github.

git commit -m "First Commit"

For window uses see answers above ^ with stored credentials


I think @deepwaters got the answer correct for older versions. The HTTPS URL needs to have the username. I had git 1.7.0.4 and git push origin master wouldn't even ask for a password till I added it.


None of the above answers worked for my enterprise GitHub account. Follow these steps for pushing via ssh key generation way.

Create a repo by visiting your git account.

Generate ssh key:

ssh-keygen -t rsa -C "[email protected]"

Copy the contents of the file ~/.ssh/id_rsa.pub to your SSH keys in your GitHub account settings. Test SSH key:

ssh -T [email protected]
clone the repo:
git clone git://github.com/username/your-repository

Now cd to your git clone folder and do:

git remote set-url origin [email protected]:username/your-repository.git

Now try editing a file (try the README) and then do:

git add -A
git commit -am "my update msg"
git push -u origin master

Update: new git version seems to recommend not to have any file while new repo is created. Hence make aa blank repo.


This 403 Error (Access denied) can occur when you haven't accepted the invite link in your email or github repo account.

After you click invitation link, you can add remote repo with following commands:

git remote add <name> <url>
git push —set-upstream <repo_name> master

Example:

git remote add ProgrammingFoundationExam https://github.com/itprowhoami/ProgrammingFoundationExam.git
git push --set-upstream ProgrammingFoundationExam master

One small addition to Sean's answer.

Instead of editing .git/config file manually, you can use git remote set-url command.

In your case it should be:

git remote set-url origin ssh://[email protected]/derekerdmann/lunch_call.git

I find it easier and cleaner, than messing around with dot-files.


Same error and resolution on Mac OS X.

Everything was working fine till I created a new account on GitHub and tried to push

$ git push -u origin master

And got the error:

remote: Permission to NEWUSER/NEWREPO.git denied to OLDUSER. fatal: unable to access ‘https://github.com/NEWUSER/NEWREPO.git/': The requested URL returned error: 403

It should have fixed by setting the user.name either for global or current repo

$ git config –-global user.name NEWUSER
$ git config user.name NEWUSER

But it didn’t.

I got it fixed by deleting the OLDUSER associated with GitHub from Keychain Access app under Passwords section. Then the push command went successful.

$ git push -u origin master

reference


Provide write access for the user.

After providing the access.Pull the code once and then push it.


I had this problem right now, and it turned out that my server /etc/resolver.conf file had a bad ip address. Might help others.


Sometimes there is nothing wrong with settings, and there are some problems on github servers.

https://status.github.com - current status of github :)


Got the same kind of error. Unable to access 403. In My Case, None of these answers worked. So i tried the below, It worked.

  1. Remove user.email and user.password from git config
  2. Remove the saved credentials from Keychain.
  3. Restart the system.
  4. Now push the code, will ask you the user/pass
  5. Proceed by giving user/pass.

Code pushed successfully

!macOS!


what worked for me is changing from http to ssh:

git remote rm origin
git remote add origin [email protected]:username/repoName.git

then check it with git remote -v


For those having permission denied 403 error while using ssh(according to Xiao) or http urls try these commands

>git config --global --unset-all credential.helper

>git config --unset-all credential.helper

with administrator rights

>git config --system --unset-all credential.helper

This has happened to me because the repository was disabled (a repository can be disabled by the owner or Github may disable all private repositories of an account if the account does not pay it's bill).

So you should contact the repository owner and inform him that the repository is disabled.


Cloning with ssh instead of https solved this issue for me

ssh cloning


In my case, I was getting the above error for my email id with github was not verified yet. GitHub was giving this warning of un-verified email.

Verifying the email, and then pushing worked for me.


Github has page dedicated to troubleshooting this error:

https://help.github.com/articles/https-cloning-errors

In my case it turned out that using a new version of git (1.8.5.2) solved this problem.


Upgrade your git. GitHub has answered this question at https://help.github.com/articles/error-the-requested-url-returned-error-403.


I am having same issue. None of the above works for me. The problem is Github has block my write permission. I have changed my password. Now I am able to push.


Make git repository from private to public.


Figured it out. I cloned over HTTPS. Setting up my public SSH keys, cloning over SSH, and pushing over SSH fixed it.


I was signed in as a different github user previously(say user1) . For my actual github account(say user2) I was able to clone a newly created repo in github but I was not able to push the changes.

I tried all the answers mentioned above including removing credential from Windows Credential manager but nothing worked.

In the end what worked was launching github Windows App. Navigate to Settings->Options and voila the logged in user was user1. Click Logout from that user and login as required user in this case user2

enter image description here


  1. Click on your repository
  2. On the right hand side, click on "Settings"
  3. On the left hand side option panel, click on "Collaborators"
  4. Add the person name you know in GitHub
  5. Click "Add Collaborators"

After this our "Push to Git" worked fine.


To definitely be able to login using https protocol, you should first set your authentication credential to the git Remote URI:

git remote set-url origin https://[email protected]/user/repo.git

Then you'll be asked for a password when trying to git push.

In fact, this is on the http authentication format. You could set a password too:

https://youruser:[email protected]/user/repo.git

You should be aware that if you do this, your github password will be stored in plaintext in your .git directory, which is obviously undesirable.


This works for me -:

git remote set-url origin https://[email protected]/user/repo.git

Hope it helps


If none of the solutions worked for you, quickly read this answer [might be your case]:

For those of you like me who went through all of these [great] answers but still have trouble pushing your commits, there is potentially one other reason for failure of a push.

Check your git repository (wherever it is, GitHub, BitBucket, ...) to see if everything is OK. In my case, after spending a lot of time figuring out what my problem is (even blaming PyCharm's new edition! :) ) I realized that I did some stupid things and my BitBucket repo exceeded the 2GB limit and automatically turned to a read-only repo and that was why I could not push any new commit. And, that exactly causes you getting the same error (403: unable to access the URL.)


For anyone curious, my mac machine vs lucid vm ran git 1.7.6 vs 1.7.0.4, and the exact same repo was pushable from my mac (newer git) but not the VM

Same curl version. Perhaps some older git versions don't support https pushes?


I don't know whether someone has mentioned this before or not.

I was having this problem with Bitbucket, and I noticed one thing. If you have this, for example,

git push https://myrepo:[email protected]/myrepo/myrepo.git --all

Notice the @ in there, right after the password. See, if your password ends with a @, you'd have two @@ instead of one. In my case, it was the password that was causing the issue.


I had the same issue. My case was: I'd initialized git repo locally before I created it on github, then I tried to add remote branch. I solved my issue by changing the order of actions: created a repo on github site, then inited it locally. But it's not the case fr them who like to do all from command line as me.


The other answers that suggest switching to SSH sort of miss the point. HTTPS is supported, but you must log in with you GITHUB password, not your SSH passphrase (which was what was giving me the same exact error).

I was having the same problem, but making sure to use my actual GitHub password at the terminal password prompt fixed the solution with no alteration to the config, or resorting to SSH.

The reason it is important to note this, is many public institutions (such as my school) will block SSH, but allow HTTPS (which is the only reason I started cloning over HTTPS in the first place).

Hope that helps anyone else having the same issue...


I had this problem because I had proxy I couldn't access to my repository

C:\Users\YourUser\.gitconfig

remove bullshit proxy and it should work

enter image description here

then try again to clone by gitbash

 git clone http://********************

enter image description here


The only thing that helped me is this answer for another question:

Git's famous "ERROR: Permission to .git denied to user"

In summary, if you are like me with Windows, search "Credential manager" and open it. There, you can find your Git credential. Change the username (which you must have changed to something else).

You can also find it under "Control Panel" - "User Account" - "Credential Manager".


Do this for a temporary fix

git push -u https://username:[email protected]/username/repo_name.git master


One another possible reason is, you might have exceeded their plan limit.

To fix this issue and restore write access to the repo, either your account plan will need to be upgraded, or some of your collaborators will need to be removed.


Try below command using administrator permission. This command solved my issue. Hope it will resolve your problem.

git config --system --unset-all credential.helper

After changing https to http within gitbox app, it worked for me.


I had the same problem with bitbucket but I waited 5 min and then I retried and it was working well. Sometimes it could be a problem with the provider.


To resolve such 403 during push error you have to go in .git directory config file and change the given line:

precomposeunicode = true
[remote "origin"]
http://[email protected]:abc/xyz.git

Change the line to this

precomposeunicode = true
[remote "origin"]
ssh://[email protected]/abc/xyz.git

This resolved my issue.


Anyone who didn't solve their problem with these solutions follow this thread:

"This happens when two git accounts are being used on same machine" https://stackoverflow.com/a/52046047/7861886

it has Windows solution and also i have added Mac solution for Mac users in comments.


This happened to me because my coworker accidentially disabled the repository that this repository was forked from. Just might check to ensure that the original git(hub) repo actually still exists.


Examples related to git

Does the target directory for a git clone have to match the repo name? Git fatal: protocol 'https' is not supported Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) git clone: Authentication failed for <URL> destination path already exists and is not an empty directory SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443 GitLab remote: HTTP Basic: Access denied and fatal Authentication How can I switch to another branch in git? VS 2017 Git Local Commit DB.lock error on every commit How to remove an unpushed outgoing commit in Visual Studio?

Examples related to github

Does the target directory for a git clone have to match the repo name? Issue in installing php7.2-mcrypt How can I switch to another branch in git? How to draw checkbox or tick mark in GitHub Markdown table? How to add a new project to Github using VS Code git clone error: RPC failed; curl 56 OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054 How to add empty spaces into MD markdown readme on GitHub? key_load_public: invalid format git - remote add origin vs remote set-url origin Cloning specific branch

Examples related to dvcs

Pushing to Git returning Error Code 403 fatal: HTTP request failed Git push won't do anything (everything up-to-date) Mercurial — revert back to old version and continue from there How do I show the changes which have been staged? How can I stop .gitignore from appearing in the list of untracked files? Undo working copy modifications of one file in Git? What's the best three-way merge tool? What is the Difference Between Mercurial and Git?