Last week I helped a friend debug a problem: Claude Code on his machine asked him to log in the moment it started, and after he logged in, it returned a 401.
It took me five minutes to spot the issue. The project gateway address his company gave him was correct, but he had put the key in the wrong variable. A one-word difference, and he spent a whole night going in circles between 401s and “please log in.”
The short version: connecting to a gateway comes down to two environment variables. But behind those two variables is a pile of pitfalls you only learn about by stepping in them, especially if you use a relay service, a company-wide gateway, or a proxy.
I’ve put together the pitfalls from that night, plus the error-reference table from the official docs, into this article.



