Android Studio will not log in to GitHub or fails to push
Can't log in to GitHub from Android StudioShort answer
Android Studio uses JetBrains' GitHub integration, which signs in with OAuth in the browser or with a token. A login or push fails when the browser login is blocked, the token lacks the scopes the IDE needs, the token expired, or the account was added for the wrong server. Re-add the account in Settings > Version Control > GitHub.
Fix it fast
1Find out which cause you have
Open Settings (Ctrl+Alt+S, or Preferences on macOS) > Version Control > GitHub and look at the account list. Note which server it lists and whether it shows an error.
# Settings > Version Control > GitHub2Match what you see, then jump to its fix
- 1
Log In via GitHub opens a browser page that never returns to the IDE.The browser sign-in did not completeFix - 2
Login works but pull requests or some Git operations fail with permission errors.The token is missing scopes the IDE needsFix - 3
A push fails with a warning that the token expired.The token expiredFix - 4
Your token is valid on github.com, but the work repository is hosted on a company server.The account was added for github.com but the repository is on an Enterprise serverFix
- 1
What does the error look like?
Can't log in to GitHub from Android StudioPush to GitHub fails because the token has expiredGit operations against a GitHub repository fail from the IDE
Cause 1 of 4
The browser sign-in did not complete
1Check
This method uses OAuth 2.0 in your browser, and with two-factor authentication you enter the code there. A blocked pop-up, a different browser profile or a firewall can stop the return.
# Settings > Version Control > GitHub > Add > Log In via GitHub2Fix
Use Log In with Token instead: click Generate in the dialog, sign in, click Generate token, paste the token and click Add Account.
# Settings > Version Control > GitHub > Add > Log In with Token3Verify
The account appears in the list with your user name.
# Settings > Version Control > GitHubConfirmed by jetbrains.com
Cause 2 of 4
The token is missing scopes the IDE needs
1Check
The IDE expects these classic token scopes: repo, gist, read:org, workflow, read:user and user:email. Fine-grained tokens are not fully supported; if you use one, grant permissions equal to those scopes.
# GitHub > Settings > Developer settings > Personal access tokens2Fix
Create a new classic token with those scopes, then paste it with Log In with Token.
# Add > Log In with Token > paste the new token > Add Account3Verify
Repeat the operation that failed.
git pushConfirmed by jetbrains.com
Cause 3 of 4
The token expired
1Check
A token with an expiry date stops working on that date. The IDE then shows a warning after the failed push.
# GitHub > Settings > Developer settings > Personal access tokens2Fix
Click Use Token in the warning, insert or generate a new token in the Log In to GitHub dialog, and click Log In.
# warning after the failed push > Use Token > Log In3Verify
Push again.
git pushConfirmed by jetbrains.com
Cause 4 of 4
The account was added for github.com but the repository is on an Enterprise server
1Check
GitHub Enterprise needs its own account entry with the server URL. github.com is used for Enterprise Cloud, example.ghe.com for data residency, and the company URL for self-hosted.
git remote -v2Fix
Choose Log In to GitHub Enterprise, type the server in the Server field, then add a token for that server.
# Add > Log In to GitHub Enterprise > Server: your server URL > Add Account3Verify
The Enterprise account is listed beside the github.com one.
# Settings > Version Control > GitHubConfirmed by jetbrains.com
How do I stop it coming back?
- Give tokens an expiry you will remember and note the date.
- Use classic tokens with the listed scopes for the IDE until fine-grained tokens are fully supported.
- Set a default account for each project so the IDE stops asking which one to use.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Mobile apps
adb cannot start because something already holds its port
adb start-server failed
The adb server must bind local TCP port 5037, and every adb client talks to it there.
2 causes, each with a fixMobile apps
The phone shows as unauthorized and Android Studio will not run the app
adb devices lists the phone but Android Studio cannot deploy to it
An unauthorized phone means it has not trusted this computer's RSA key.
3 causes, each with a fixMobile apps
Android Studio cannot pair the phone over Wi-Fi
The Pair devices over Wi-Fi dialog lists no device
Wireless pairing needs the phone on Android 11 or higher and on the same Wi-Fi network as the computer, with current Platform-Tools.
4 causes, each with a fixMobile apps
adb cannot connect to its daemon or start the server
* daemon started successfully *
The adb server is a background process on your computer that listens on TCP port 5037.
2 causes, each with a fixMobile apps
adb prints 'server version doesn't match this client; killing...'
adb server version doesn't match this client; killing...
adb runs a background server, and every adb command is a client.
3 causes, each with a fixMobile apps
adb tcpip 5555 fails because no device is found
adb: more than one device/emulator
adb tcpip only works while the device is attached and listed by adb, because it tells the phone to start listening on port 5555.
4 causes, each with a fix