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

75

830

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
Yalta answered 15/9, 2011 at 22:45 Comment(13)
Look at the comment, which should be posted as an answer. Made it work with 1.7.1, had the missing User/Password prompt problem, too. Props to https://mcmap.net/q/53703/-pushing-to-git-returning-error-code-403-fatal-http-request-failed ...Quatrefoil
check the user has read/write access to the repositorySublime
In the future, don't paste "Authorization: Basic <stuff>" when showing example http headers. It's easy to base64 decode that and get your password. @mike: if you haven't changed your github password since you posted this question, I would suggest you do so.Tetreault
@Tetreault Thanks man. Was unaware. Password changed.Yalta
Note that at least git 1.8 automatically responds to the Forbidden message by prompting for a username, rendering all of this tinkering with remote URLs unnecessary. Thus if you're finding some machines prompt you for credentials and some respond "403 Forbidden," check whether one is using git 1.8 and the other an earlier version.Pyroxylin
I am using "Github for Windows" and had similar issue when switched between two Github accounts. Here's my solution: #18566376Gymkhana
I don't understand, why is this problem happening in the first place?Ochone
In my case my personal access token on github was not setup to grant permission to the repository. Check that repo Full control of private repositories is checked under "Edit personal access token"Mindful
In windows could just be a credentials issue. There is an answer by Andrew Gans below that mentions it. I put the full solution that worked for me from another post in a comment to that answer.Neely
In my case I was behind a company proxy, which (in some way I can't figure out) caused problems. From my home network I was able to push using the https url without problems. I used this guide to set the remote url: github.com/Hervian/aop-logging.gitMinify
See here for a solution: janac.medium.com/…Cristophercristy
You should tr and follow the steps in this linkPhosphorate
in my case, it was .gitconfig. Make sure you align the username in the .gitconfig to the username in github.com/<user_name>/<repo>.gitVinosity
S
1009

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:
    url=ssh://[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.
Sump answered 14/10, 2011 at 18:26 Comment(18)
This is often encountered when you clone with the git read-only address (which is the default when you aren't logged in) instead of the read+write ssh address.Genisia
My .git/config was more like url=https://github.com/mynickname/my_repo.git But I also changed it like url=ssh://[email protected]/mynickname/my_repo.git and it did the trickDaggna
You can change a repo url with git remote set-url command. See my answer below.Payroll
or simply change it from the command line using git remote set-url <name> [email protected]:<username>/<repo>.gitDelve
this problem happened after i switched to using homebrewWallraff
Sorry, but this is a band-aid solution. SSH is not an option for everybody. Github does support HTTPS. You're saying that Github says Read/Write is supported over HTTPS but somehow it doesn't actually support it? I don't think that's the case here. Rather, instead of finding out what was wrong with the HTTPS connection, we will just use SSH and ignore the problem.Anglian
i have to do this every time i create a new repository. why? how can i change it permanently?Carincarina
For those looking for a non ssh solution, check a few of the other answers here. Adding your username to the https url seems to work. (change config url so that https://@github.com/... is [email protected]/...)Stochmal
I have created many repos before, and I'm positive that I was logged in to the github website when I created this one, nevertheless I had this issue happen (for the first time). BTW, I am using the SourceTree GUI, so I edited the remote's URL in the repo's settings panel.Cham
I'm trying to edit '.git/config' on the repo 'Chronicle.git' by putting in 'pico config' which returns: 'repositoryformatversion = 0 filemode = true bare = true' I don't see a field titled 'url'. Am I going about this the wrong way?Blavatsky
If you are using Phabricator and encountered the 403 error, it might be because you didn't set the VCS (version control password) - which you provide when trying to access the remote repoLyssa
No, this doesn't solve the problem for me. I've changed config as described, but push gives me The authenticity of host 'github.com (192.30.252.129)' can't be established. RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'github.com,192.30.252.129' (RSA) to the list of known hosts. Permission denied (publickey).Forewing
you will also need to add ssh public key to your github account do the following : 1.Generate a new SSH key With the command line still open, copy and paste the text below. Make sure you substitute in your GitHub email address. ssh-keygen -t rsa -b 4096 -C "[email protected]" 2.Add your key to the ssh-agent configure the ssh-agent program to use your SSH key: eval "$(ssh-agent -s)" 3.Add your SSH key to your account -In your favorite text editor, open the ~/.ssh/id_rsa.pub file. -Click Add SSH key in your github setting accountArchimage
in my case the URL is of this format url = https://github.com/viveksinghggits/bethere.git. I think I logged into GIT with another user earlier some time. This is the exact error that I am getting: remote: Permission to viveksinghggits/bethere.git denied to vivekstudent. fatal: unable to access 'https://github.com/viveksinghggits/bethere.git/': The requested URL returned error: 403Embry
In my case, I was trying to commit as I worked from home. I remembered to connect to my company's VPN, and voila. My mistake.Chesson
sorry.. can somebody help - where to find .git/config file?Unclog
Changing the URL worked for me without the 'ssh://' prefix. Thank you!Weathered
@rishijain bit late but maybe someone else will encounter the same issue: In my case I use SourceTree. In SourceTree go to: Repository --> Repository settings --> Edit Config File. Else the file is located in the .git folder called: "config" (With no extension). Hope it helps.Radiculitis
I
524

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.

Infirm answered 6/7, 2012 at 19:41 Comment(20)
SSH blocked at work so I have to use HTTPS. Adding the username fixes my issues.Wording
This should be the accepted answer. No reason to manually edit a config file when there's a command line interface to it.Birkner
Also, for me, this way (username@github...) asked for password and worked, whereas ssh://git@github... failed expecting public key auth.Birkner
works and should be the accepted answer! Especially in environments in which ssh does not work, this is the way to go. Thanks!Ranitta
Why exactly does this work, if you don't mind giving an explanation?Linguistic
@Linguistic it's an authentication format. You could set your password too https://youruser:[email protected]/user/repo.git despite not secureInfirm
Don't forget that in GitHub, you need to work on your forked project in order to participate to a project (and do a pull request to the master).Ardennes
I tried using https://[email protected]/user/repo.git on my bosses server. I got this message (gnome-ssh-askpass:21776): Gtk-WARNING **: cannot open display: I went and changed it to https://username:[email protected] ... and now it works, but I was not happy having my password in the plain text file like that so I went and changed it back I wish there was a --password flag so you could use the first option if for some reason the system security wont let you get the password prompt.Magneton
@Magneton checkout this thread #11506624Infirm
It's worth adding that you don't need to add your username to the URL for each repository, you can instead set it in global config: git config --global credential.https://github.com.username YOUR_USERNAMEWatermark
I get fatal: No such remote 'origin'Paten
Thanks Thiago, works like a charm... Should be the accepted answer for sure.Catchings
I agree that it should be the right answer, because It is the solution for the https connection to the repo. In this context, where you are cloning the repo by https, talk about suggestion to change to ssh is like a workaround... and It is true that something (like where you are working behind a corporate proxy) connecting to a repo by ssh is not an option ... thanks +Thiago Fernandes, It help meVip
Just a note if you have this problem, if you have special characters in the username or password you need to URL encode them. For example, @ needs to be %40.Culbreth
Worked for me with bit bucket, in fact did not need to run second command as it asks for password when pushing the change.Zoophobia
thanks, youruser:[email protected]/user/repo.git this solved my problem!!!Erechtheus
Good to note that the username needs to be URL-encoded. So if your username is your email, for example, you need to change @ character from your username to %40. But this answer worked for me, thank you.Cuneal
FYI, this trick keeps it from prompting me for my username (and password as well, if I put that in the url), but I still get the 403 that OP mentioned.Bacchant
Password based authentication is now removed. github.blog/…Gerdes
This is what worked for me. This answer is correct.Barilla
P
134

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.

Payroll answered 4/6, 2012 at 22:29 Comment(1)
I don't know if this is just an old post and git has changed, but as today to fix the problem I had to use git remote set-url origin ssh://[email protected]:derekerdmann/lunch_call.git with a colon between the github.com and the repo nameGrolier
T
68

Edit .git/config file under your repo directory

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

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

where USERNAME is your github user name

Tishtisha answered 7/11, 2012 at 9:39 Comment(3)
This answer did not apply to my problem. My url in .git/config is set to `github.com/myrepo/subproject'.Category
Had this problem with Android Studio. Works fine.De
My instinct is that this is more along the lines of being the right answer because other solutions either switch to SSH protocol or store password in plaintext.Dyanna
M
52

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...

Margaritamargarite answered 17/1, 2012 at 17:27 Comment(5)
but why? I didn't have to do that in the past. Did a certificate expire, or something?Footlights
Not sure, I'm not an expert, that's just how I got it to work in my case :)Margaritamargarite
Same @Thufir. I have no idea why this suddenly worked.Ziguard
I log on just fine with my username and password on the browser. BUT when i try to git push I am prompted for a u and p and the result is permission denied.... Do you know what I am missing?Leggat
As of recently (2021?) when prompted for the password, you must use a generated token (oauth), generated at the GitHub website under User Settings / Developer Settings / Personal access tokens. And that generated token must include the "repo" scope.Varner
C
46

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.

Concourse answered 18/4, 2018 at 7:34 Comment(3)
"You may have to check windows credential manager and delete the github entry under control panel > user accounts > credential manager > Windows credentials > Generic credentials " details from this post: stackoverflow.com/a/37450495Neely
exact answer (working for me perfectly)Clareclarence
Yes, it did the trick, other answers weren't working. After delete git:username under "Windows credentials > Generic credentials" then use the token for the password in CMD when asked after push command.Durfee
I
33

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

Izanagi answered 10/11, 2014 at 11:36 Comment(2)
Deleting the OLDUSER from the Keychain Access App worked for meHuff
I got the same error, but for a different but related reason that required a different solution. I was trying to push to a repo where I don't have write access (I'm not a collaborator). This was more due to my lack of knowledge of how to contribute to a repo that isn't mine. I thought I could just create a new branch and then do a pull request. Not so. I have to fork the repo first, make my changes on the fork, then do a pull request from my forked repo to the original repo. Probably a dumb mistake on my part, but if I can make it, then I'm sure other n00bs could. :)Appreciative
S
23

This works for me -:

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

Hope it helps

Siphonophore answered 27/9, 2015 at 21:41 Comment(2)
nice job. set user!Tagmemics
This solution helped with git v1.7 in CentOS 6.10 x86. I was expecting the password promopt to show up (instead of SSH key), and it did (by prepending <username>@ before github.com in remote URL). Thank you!Patina
M
20

A lot of answers here, but this is what solved my problem.

Since July 2020 you must use Token authentication to access GitHub if you are using HTTPS.

So you must generate an access token in your profile settings page and use it as your password. Check the boxes necessary to write to the repository.

Now add your username to the repo with this command:

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

When you try to push, it will ask for your password. Enter your newly generated token.

If you are still having trouble pushing, use the web interface to fork it as a personal repo to isolate any permission problem. You'll be able to focus on solving the auth problem.

Maxantia answered 29/7, 2021 at 23:58 Comment(0)
A
19

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.

Algology answered 27/6, 2012 at 14:44 Comment(0)
E
16

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

Exoskeleton answered 20/6, 2012 at 19:3 Comment(1)
It's half the answer, for sure. Other half is what we have here.Yalta
H
15

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

Habituate answered 16/9, 2011 at 0:32 Comment(3)
Me and a friend are having the same problem. The repo is mine, and he can't push. How do we fix this?Silicle
how to get persmissonStoned
add your friend into the access list of repo. help.github.jp/enterprise/2.11/user/articles/…Kepner
Y
12

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

Yalta answered 16/9, 2011 at 3:29 Comment(3)
Hmmm... but what when you can't use anything but https, because of a corp firewall, for instance?... According to the github blog, the https access was added to github just for that purpose?Bract
I really don't know. I always clone over SSH now.Yalta
Just for posterity (I noticed the timestamp), in regards to filofel's comment: Check out my answer listed above. I have the same restriction you mention, at my school, and found I was supplying the wrong password/passphrase to the terminal prompt. Hope it helps any others with the same issue.Margaritamargarite
M
11

Do this for a temporary fix

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

Mahogany answered 19/9, 2018 at 15:41 Comment(0)
A
10

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

Algo answered 2/3, 2014 at 14:54 Comment(2)
Not stupid, this is the correct answer for most first-time contributors to public repositories.Nadabas
Thanks a lot. Was a first-time contributor to a public repository. This was my issueDram
A
10

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
Actual answered 13/10, 2015 at 23:0 Comment(3)
^ this (or any one of its variants below)Portuna
Adding the username before github.com fixed it for me.Bringingup
You are welcome @ÅdəəlÅhmåd . Support the effort by upvoting the answer so that many others can appreciate.Actual
H
9
  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.

Henslowe answered 13/3, 2015 at 13:38 Comment(0)
N
7

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 "@".

Nebulous answered 18/10, 2012 at 1:7 Comment(1)
It worked for me (using CentOS Server with RStudio behind proxy). Set proxy first : git config --global http.proxy http://proxyUsername:[email protected]:port Then use the command git remote set-url origin to switch the adress.Exceedingly
C
7

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.

Commonable answered 13/4, 2020 at 9:27 Comment(0)
B
5

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
Bosom answered 12/1, 2017 at 18:17 Comment(1)
Now every time Git will ask for login and password. Save them through git config --global credential.helper store.Mobcap
U
5

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.

Unemployment answered 13/2, 2018 at 7:2 Comment(1)
This answer helped me, but you must be sure that your keys have default names like id_rsa and id_rsa.pub, otherwise, you will continue to get the error Permission denied (publickey,keyboard-interactive). fatal: The remote end hung up unexpectedly. So either rename your key to the default name or use this answer to clarify how to set a custom path to ssh key.Eger
X
5

if you get 403 error with github,

sure to check all checkboxs when create token:

https://github.com/settings/tokens

i think github token generate page has design flaw.

Xenophon answered 1/3, 2022 at 3:18 Comment(0)
C
4

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.

Clarinda answered 26/8, 2016 at 17:13 Comment(0)
H
4

I faced similar issue and most of the answer did not work in my case, i was getting permission denied 403 forbidden error. Following steps helped me to resolve the issue:

Install git CLI by below command if you have brew installed:

brew install gh

Reference to install git CLI https://github.com/cli/cli#installation

then run

gh auth login  

it will ask you following questions, answer like this,

What account do you want to log into? GitHub.com
? What is your preferred protocol for Git operations? HTTPS
? Authenticate Git with your GitHub credentials? Yes
? How would you like to authenticate GitHub CLI? Login with a web browser

It will generate code for you, enter generated to code your browser for authentication.

! First copy your one-time code: 14*B-E2*7

Press Enter to open github.com in your browser... 
✓ Authentication complete.

By following above steps you will be able to push code to your repository.

Hyoscyamine answered 6/2, 2023 at 17:42 Comment(0)
R
3

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?

Rahm answered 5/3, 2012 at 23:49 Comment(2)
Yes, https push to github works here (even through proxy with password). I use git 1.7.3. For me, it failed first because I typed the wrong password.Pebble
It works for me with git 1.7.1, but there is one thing you have to pay attention too (and that was what I missed in my first try): Give the user name in the HTTPS-URL, i.e. url=https://[email protected]/username/repo.gitMedicate
U
3

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:

Unfrock answered 5/3, 2016 at 15:1 Comment(0)
A
3

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

git config --system --unset-all credential.helper
Andras answered 25/4, 2020 at 18:3 Comment(1)
This command reset all user credentials. And let user to give user id and token again. For my case issue resolve by doing this. I was logged in another git account.Santamaria
S
3

If SSH is not allowed for some reason, HTTPS is also ok.

To push the commits by HTTPS, you should use the personal access token and make sure the read and write is available in Scopes which define the access for personal tokens.

Setting in GitHub as follows.

enter image description here

Shiner answered 11/12, 2021 at 14:11 Comment(0)
F
2

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"
Flotsam answered 17/2, 2014 at 21:8 Comment(1)
Does not work for me. Config has been set, use github.com.. with no '@' in itDeleterious
C
2

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.

Cholecystitis answered 27/9, 2014 at 13:23 Comment(0)
L
2

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://mcmap.net/q/55041/-git-returning-error-403-while-pushing-the-code-duplicate

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

Lossa answered 16/7, 2020 at 20:58 Comment(0)
C
2

For windows Go to "Control Panel\User Accounts\Credential Manager" and remove the entry shown in the figure and push with username/password.

Credential Manager

Clareclarence answered 16/9, 2022 at 9:46 Comment(0)
T
1

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.

Thermistor answered 29/8, 2012 at 11:57 Comment(0)
S
1

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.

Subtonic answered 3/12, 2012 at 15:24 Comment(0)
G
1

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.

Garling answered 7/5, 2013 at 0:1 Comment(0)
R
1

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

Ryder answered 22/1, 2014 at 9:59 Comment(0)
P
1

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.

Pupa answered 15/2, 2014 at 20:9 Comment(0)
H
1

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

Heger answered 10/3, 2014 at 19:13 Comment(1)
got 403 while accessing by http.Deleterious
I
1

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

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

Igal answered 1/4, 2014 at 23:23 Comment(1)
You can also get GitHub status updates from their Twitter status account.Sheriesherif
M
1

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.

Mesonephros answered 2/6, 2014 at 18:11 Comment(0)
C
1

Cloning with ssh instead of https solved this issue for me

ssh cloning

Category answered 19/7, 2015 at 0:7 Comment(0)
A
1

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

Anagnos answered 26/4, 2016 at 15:2 Comment(0)
P
1

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!

Pic answered 30/5, 2017 at 13:58 Comment(0)
P
1

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".

Pocosin answered 14/1, 2018 at 23:10 Comment(0)
O
1

Make git repository from private to public.

Orosco answered 24/2, 2021 at 3:56 Comment(1)
i don't recommend doing that at all, keep it private, use access token and give permissions for that token ! you will find it here : github.com/settings/tokensFlirt
M
1

I had solved this issue of Permission denied by just:

1.) upgrading the git to latest version.

2.) Changing remote url to the format "https://[email protected]/username/repo_name.git" through command entered in git-bash "git remote set-url origin https://[email protected]/username/repo_name.git"

Previously, I was using the version 2.28 so I was not getting the Login Screen Prompt. Also by changing the url I was able to login with git-hub credentials and push the changes to the repo

Marienbad answered 27/11, 2021 at 11:25 Comment(1)
Indeed, the outdated Git cli on the old machine was the reason, trying the same commands from the recent version on my new laptop solved it.Eolande
C
1

The support for password authentication while accessing Github from CLI(Command Line Interface) has been removed on August 13, 2021 by replacing them with personal access token.

Steps to create personal acess token

By default tokens always include read-only access to all public repositories on GitHub. Hence, to give push or pull and rights you need to select the appropriate "Scope" while generating the access token.

The scope for public repositories is public_repo, and for private repositories is repo. A token with one of those scopes is the most limited access possible for Git push or pull access.

Now, when you are prompted for your username and password, provide your GitHub username and the access token in place of the password.

For the description of other available scopes refer the Github Documention

Cr answered 3/11, 2022 at 18:2 Comment(0)
E
1

Just to add one more scenario that happened to me, my company requires SSO hence when I created/renewed my new publishing token I forgot to authorize it and started to get these 403 responses from github:

enter image description here

enter image description here

I suspect this distraction might be common

Externalization answered 19/1, 2023 at 12:0 Comment(0)
D
0

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.

Dicks answered 30/4, 2013 at 8:27 Comment(0)
S
0

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

Saltworks answered 3/10, 2013 at 1:44 Comment(0)
B
0

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.

Bradski answered 29/7, 2014 at 13:16 Comment(2)
Hmm, just like what this guy says about GitHub servers, yeah?Sheriesherif
You can get Bitbucket status updates from their status page and maybe also their Twitter account.Sheriesherif
R
0

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.

Revisionism answered 22/4, 2015 at 13:11 Comment(0)
P
0

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.

Phonolite answered 19/10, 2015 at 6:37 Comment(0)
J
0

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.

Jiles answered 18/12, 2017 at 12:23 Comment(0)
T
0

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.)

Terrenceterrene answered 20/9, 2018 at 23:53 Comment(0)
A
0

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

Aerometry answered 30/11, 2018 at 8:53 Comment(0)
B
0

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

Bystreet answered 9/2, 2019 at 1:13 Comment(0)
M
0

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

Meshuga answered 19/3, 2019 at 5:46 Comment(0)
E
0

Provide write access for the user.

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

Elora answered 27/5, 2019 at 13:28 Comment(0)
E
0

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

Ethyl answered 30/6, 2019 at 17:30 Comment(0)
S
0

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

Spacing answered 4/8, 2019 at 6:40 Comment(0)
V
0

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.

Vansickle answered 28/9, 2019 at 21:5 Comment(0)
M
0

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.

Millipede answered 29/9, 2019 at 7:6 Comment(0)
Z
0

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.

Zoara answered 13/11, 2019 at 10:17 Comment(0)
S
0

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
Sigmund answered 9/12, 2019 at 15:52 Comment(0)
T
0
  1. Check if you are on the correct branch git status
  2. Check your repository permissions (write permission is needed)
Topcoat answered 1/2, 2020 at 14:59 Comment(0)
Z
0

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.

Zaffer answered 23/6, 2020 at 16:2 Comment(0)
K
0

I am using a Mac and got the error fatal: unable to access The requested URL returned error: 403.

I did change my GitHub account details.

I had to edit my keychain entry for GitHub and update the username to the new username. You can easily find KeyChain in the top search of the MAC.

Kyongkyoto answered 10/4, 2021 at 22:17 Comment(0)
S
0

I faced the same problem and noticed that the repository I was trying to push my branch was private. So, try the following procedure:

  1. Make sure you have access to that private repository

  2. Fork the repository first. You will notice that the repository URL will contain your GitHub username

  3. Clone it now like this --> git clone https://github.com/your-github-username/example-repository.git

  4. Enter in the cloned repository folder --> cd repository-directory

Do whatever you want to do with your cloned repository. Staying in the same cloned repository directory move to the next steps

  1. Check all the branches. This will list up the available branches --> git branch

  2. Create your branch now --> git checkout -b your-branch-name

  3. Run git branch to check if your branch is created

  4. Now run this command --> git add .

  5. Commit your changes --> git commit -m "your message"

  6. Push your branch --> git push origin your-branch-name

  7. Check GitHub site to make sure your branch is pushed now

That's All

Salesmanship answered 20/5, 2021 at 14:28 Comment(0)
T
0

This error happened when we clone someone repository from github. this might easily be solve by updating origin by using

git remote set-url origin 'Your repository origin'

then after this apply

git push -f origin master

This might be very helpful for all

Timer answered 2/10, 2021 at 7:55 Comment(0)
S
0

I faced similar error

fatal: unable to access 'https://gitlab.com/xxxx/yyyy.git/': The requested URL returned error: 403

I resolved by switching network, ( by changing IP). initially, I faced an issue in my system, then I tried with new network (by using a mobile hotspot) and did a git pull,

again I moved back to the primary network, and i was able to perform all git operations with no issues.

Swellfish answered 22/12, 2021 at 9:43 Comment(0)
S
0

If no other methods worked, try this:

  • McOS only
  1. Go to Finder, search for the Keychain Access.
  2. While in Keychain Access, search for github.com.
  3. Then look for internet password double click that.
  4. Once double clicked, look for show password then enter your computer password to access it.
  5. You should now be able to edit or delete the current token. After you've edited the token or deleted it save your changes and you should be able to push your code.

Hope this helped.

Subtractive answered 6/12, 2022 at 23:52 Comment(0)
C
0

I faced the same issue The requested URL returned error: 403 in android studio.

I have followed the below steps:-

  1. Right-click in project name ---> git ----> add
  2. After that open one dialog ----> Enter generate the by GitHub.
  3. Then Write the Commit message ----> And Select the Push option.

Note:- So you must generate an access token in your profile settings page and use it as your password.

Coranto answered 22/4, 2023 at 16:9 Comment(0)
E
-3

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

Estevan answered 13/4, 2017 at 11:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.