Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

github

dvcs

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 
like image 928
Mike Avatar asked Sep 15 '11 22:09

Mike


People also ask

How do I fix 403 error in GitHub?

Rectifying the “403 Forbidden” Error Message There are two methods to fix the HTTPS address to resolve the 403 error in question; Method 1. Use SSH to push the changes to GitHub. First, connect to your hosting server via SSH then follow the instructions Github provides to add a remote repository.

How do I fix 403 status code?

Many times the 403 error is temporary, and a simple refresh might do the trick. Most browsers use Ctrl+R on Windows or Cmd+R on Mac to refresh, and also provide a Refresh button somewhere on the address bar. It doesn't fix the problem very often, but it takes just a second to try.

What is the meaning of HTTP status code 403?

The HTTP 403 Forbidden response status code indicates that the server understands the request but refuses to authorize it. This status is similar to 401 , but for the 403 Forbidden status code re-authenticating makes no difference.


2 Answers

I just got the same problem and just figured out what's cause.

Github seems only supports ssh way to read&write the repo, although https way also displayed 'Read&Write'.

So you need to change your repo config on your PC to ssh way:

  1. edit .git/config file under your repo directory
  2. find url=entry under section [remote "origin"]
  3. change it from url=https://[email protected]/derekerdmann/lunch_call.git to [email protected]/derekerdmann/lunch_call.git. that is, change all the texts before @ symbol to ssh://git
  4. Save config file and quit. now you could use git push origin master to sync your repo on GitHub
like image 153
Xiao Avatar answered Oct 08 '22 20:10

Xiao


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.

like image 26
Thiago Macedo Avatar answered Oct 08 '22 21:10

Thiago Macedo