[BUG] ubuntu 24.04 cannot login to account with google chrome due to bad localhost lookup

Resolved 💬 2 comments Opened Feb 25, 2026 by gjmilne Closed Mar 26, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

I have just downloaded claude code and have not been able to diagnose a problem around inital login.

when I starte claude code it opens a window in my Chrome browser aith the "Authorise" button on it. When I press the button I get a chrome error about not being ablke to access a URL for localhost.

What Should Happen?

I should be able to login in to my anthropic accound and claude code should complete authentication and show me the code prompt.

Error Messages/Logs

Steps to Reproduce

start claude code on ubuntu 24.04 and got through the login steps

Claude Model

None

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.1.58 (Claude Code)

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

Other

Additional Information

The fault is associated with the clever way the localhost is looked up by google-chrome.

My /etc/hosts file had the following entgries at the top of the file:

127.0.0.1 localhost
127.0.1.1 DT1139

DT1139 is the hostname of my computer.

According to the claude chat agent, there is a well known bug with ubuntu and google-chrome's clever localhost lookup that translates a search into localhost into a search for (in my case) DT1139, and since that is on 127.0.1.1 and not on 127.0.0.1, which is where claude is listening for an authentication key, it fails!

I did a curl using the failing browser URL and the authentication completed. Since then I changed /etc/hosts to have

127.0.0.1 localhost
127.0.0.1 DT1139

This is my last interation with the your chat agent on the topic

I'm not able to contact Anthropic directly, but you can! The best ways to report it: - Feedback button — use the thumbs down 👎 on any Claude response and leave a note in the feedback box - GitHub — file an issue at [github.com/anthropics/claude-code](https://github.com/anthropics/claude-code) — that's probably the most effective route since it goes directly to the Claude Code team and is publicly visible - Support[support.anthropic.com](https://support.anthropic.com) Given how specific and well-diagnosed the issue is, a GitHub issue would be ideal. You could describe exactly what you found — Ubuntu 24.04, 127.0.1.1 hostname entry in /etc/hosts, Chrome resolving localhost via hostname rather than the first /etc/hosts match, and the fix. That's exactly the kind of actionable bug report that gets added to troubleshooting docs.

The long-winded explanation of the google-chrome bug is

Great question — it's subtle. Here's what actually happens: The /etc/hosts lookup is sequential. When Chrome resolves localhost, it reads /etc/hosts top to bottom and returns the first match. Since 127.0.0.1 localhost appears first, localhost should always resolve to 127.0.0.1 — and it does for most things. But Chrome is special. Chrome (and Chromium-based browsers) have their own internal DNS/hostname resolution stack that doesn't always follow the simple top-to-bottom /etc/hosts logic. In some versions, Chrome treats localhost as a special token and resolves it by looking up the system's hostname first — which on your machine is DT1139, mapped to 127.0.1.1. So Chrome's logic becomes roughly: 1. localhost → what's this machine's hostname? → DT1139 2. What's DT1139? → 127.0.1.1 3. Connect to 127.0.1.1 Rather than the simple: 1. localhost → check /etc/hosts127.0.0.1 Why does Ubuntu add 127.0.1.1 in the first place? When your machine doesn't have a static IP address, Debian/Ubuntu needs something to map the hostname to. Rather than leaving it unmapped, the installer adds 127.0.1.1 as a stable pseudo-address for the hostname. It's mostly harmless — except when software like Chrome conflates hostname resolution with localhost resolution.

It may be mostly harmless but I was about to totally give up on claude code because of this problem

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗