Skip to content
Claude Code Beginner

Claude Code Beginner

  • Start Here
  • Learn
  • Cheatsheet
  • About
  • Contact
  • Glossary

Claude Code Login Problems — How to Fix Them

by Jay

You installed Claude Code, you ran claude, and now something is going wrong with the login. Maybe the browser didn’t open. Maybe you got an error message. Maybe you authenticated in the browser but Claude Code still says you’re not logged in.

This guide covers every common Claude Code login problem and exactly how to fix each one.

This is part of our complete Claude Code Beginner’s Guide.


TL;DR

  • Claude Code login requires a paid Anthropic account — free accounts don’t work
  • If the browser doesn’t open automatically, look for a URL in the terminal and paste it manually
  • If login succeeds in the browser but fails in the terminal, try claude again in a new terminal window
  • Network issues (VPNs, firewalls, corporate proxies) are the most common cause of persistent login failures
  • Run claude doctor to get a diagnostic report on your auth state and network

How Claude Code Login Works

Understanding the login flow helps diagnose what’s broken.

When you run claude for the first time, Claude Code tries to open a browser window automatically. You log in to your Anthropic account in the browser, authorize Claude Code to use your account, and the browser sends a confirmation back to the terminal. From that point on, Claude Code stores your credentials locally and logs you in automatically on future sessions.

If any step in that chain breaks — the browser doesn’t open, the authorization doesn’t get back to the terminal, or your credentials aren’t stored — you’ll hit a login error.


Problem 1: “Authentication required” or Login Prompt Loops

What you see: Claude Code keeps asking you to log in, even though you already did.

Most likely cause: Your credentials didn’t save properly, or the terminal didn’t receive the authorization response.

Fix:

First, make sure you’re completing the login in the browser, not just closing the window. After you click “Authorize” in the browser, you should see a success message and the terminal should update.

If the terminal is still stuck, try explicitly running the auth command:


# Force the Claude Code authentication flow to restart
claude auth login

This explicitly starts the login process. If a browser opens and you authorize successfully, the session should authenticate.


Problem 2: The Browser Doesn’t Open

What you see: You run claude and nothing happens, or you see a message like “Opening browser…” but no browser appears.

Most likely cause: Claude Code couldn’t open your default browser — common on headless servers, Linux without a desktop environment, or systems with unusual browser configurations.

Fix: Look in your terminal output for a URL. It will look something like:


Please visit this URL to authenticate:
https://claude.ai/auth?code=xxxxx...

Copy that URL and open it manually in any browser — even on a different device if you’re on a server. Log in with your Anthropic account, authorize Claude Code, and the terminal will pick up the confirmation.

💡 Pro Tip: On Linux servers without a GUI, this is the standard login flow. Don’t wait for a browser to appear — just look for the URL and paste it into a browser on your local machine.


Problem 3: “Free plan does not include Claude Code”

What you see: After logging in, Claude Code tells you your account doesn’t have access.

What this means: You’re logged in to the correct account, but it’s on the free tier. Claude Code requires a paid plan.

Fix: Upgrade your account at claude.ai/upgrade. The minimum plan for Claude Code access is Pro at $20/month.

After upgrading, run:


# Log out and back in to refresh your account permissions
claude auth logout
claude auth login

This forces Claude Code to re-check your account status and pick up the new plan.

For details on what each plan includes, see Claude Code Pricing — Free vs Pro vs API Explained.


Problem 4: Login Succeeds in Browser but Terminal Shows Error

What you see: The browser says “Successfully authorized Claude Code” but the terminal shows an authentication error or hangs.

Most likely cause: The callback from the browser to the terminal failed — often due to a network restriction or a timing issue.

Fix steps:

First, try again in a new terminal window:


# Open a fresh terminal and try authenticating again
claude auth login

If that doesn’t work, check if your system has anything blocking local network connections. Some security tools block applications from receiving HTTP callbacks on localhost. Try temporarily disabling any firewall or security software and authenticating again.

If you’re on a corporate machine, ask your IT team whether localhost callbacks are allowed.


Problem 5: Network or Firewall Blocking Authentication

What you see: Login hangs indefinitely, times out, or returns a network error.

Most likely cause: A VPN, corporate firewall, or proxy is blocking Claude Code’s connection to Anthropic’s servers.

Claude Code needs to reach:

  • api.anthropic.com
  • claude.ai

Fix:

First, disable your VPN temporarily and try again:


# Check if Claude Code can reach Anthropic's servers
claude doctor

claude doctor includes a network connectivity check and will tell you if it can reach the API. Look for a line like Network: Connected or Network: Failed.

If you’re on a corporate network, you’ll need to work with your IT team to allowlist api.anthropic.com and claude.ai through the firewall or proxy.


Problem 6: ANTHROPIC_API_KEY Environment Variable Conflict

What you see: Claude Code prompts you to approve an API key instead of opening a browser login.

What’s happening: You have an ANTHROPIC_API_KEY environment variable set on your system. When this variable exists, Claude Code uses it instead of the browser-based login flow.

If you want to use API key authentication: Follow the prompt to approve the key. This is the correct flow for API-based access.

If you didn’t intend to set an API key: Check your shell profile for the variable:


# Search for ANTHROPIC_API_KEY in your shell profile files
grep -r "ANTHROPIC_API_KEY" ~/.zshrc ~/.bashrc ~/.bash_profile ~/.profile 2>/dev/null

If you find it, remove that line from the file, then open a new terminal and run claude again to get the normal browser login flow.


Problem 7: “Token expired” or Logged Out Unexpectedly

What you see: Claude Code worked before but now says your session has expired or you need to log in again.

What’s happening: Auth tokens expire periodically. This is normal and expected.

Fix: Run the login flow again:


# Re-authenticate Claude Code
claude auth login

This is quick — if your browser is already logged in to Claude.ai, you’ll just need to click “Authorize” and you’re back in.


Problem 8: Logged In to the Wrong Account

What you see: Claude Code is authenticated but it’s using the wrong Anthropic account (e.g., a personal account instead of your work account, or vice versa).

Fix: Log out first, then log back in with the correct account:


# Log out of the current Claude Code session
claude auth logout

# Log in again — the browser will let you choose or switch accounts
claude auth login

In the browser, sign out of the current Anthropic account first if needed, then sign in with the right one.


Run a Full Diagnostic

When something is wrong and you’re not sure what, run:


# Print a full diagnostic report of your Claude Code installation and auth state
claude doctor

This covers your installation health, auth state, network connectivity, settings files, and any detected issues with suggested fixes. It’s the fastest way to get a clear picture of what’s broken.

Look for lines marked with ✗ or warnings — those are the items to address.


Key Takeaways

  • Free accounts don’t work** — Claude Code requires Pro, Max, Team, Enterprise, or Console
  • Browser doesn’t open?** Look for a URL in the terminal and paste it manually
  • Auth completes in browser but terminal fails?** Try a new terminal window and claude auth login
  • VPN and firewalls** are the most common cause of persistent network login failures
  • ANTHROPIC_API_KEY set?** It overrides browser login — remove it if you didn’t intend this
  • claude doctor** is always the first diagnostic step when something feels broken

Next Steps

  • Check your plan**: Claude Code Pricing — Free vs Pro vs API Explained
  • Reinstall if needed**: How to Install Claude Code on Mac, How to Install Claude Code on Windows, or How to Install Claude Code on Linux
  • System requirements check**: Claude Code System Requirements — What Do You Need?

Return to the Claude Code Beginner’s Guide for the full learning path.

Categories Getting Started Tags anthropic login issues, claude code auth fix, claude code authentication error, claude code login fix, claude code login problems, claude code not logging in
How to Uninstall Claude Code
Claude Code Keyboard Shortcuts — The Complete List
All rights reserved © 2026 ~ ClaudeCodeBeginner.com