BUG(23) : node版claude code启动报错Failed to connect to api.anthropic.com: ETIMEDOUT

1.安装命令

复制代码
npm install -g @anthropic-ai/claude-code

环境 : ubuntu:22.04容器内部

2.启动报错信息

Welcome to Claude Code v2.1.77

..............................................................................................................................................................................

* █████▓▓░

* ███▓░ ░░

░░░░░░ ███▓░

░░░ ░░░░░░░░░░ ███▓░

░░░░░░░░░░░░░░░░░░░ * ██▓░░ ▓

░▓▓███▓▓░

* ░░░░

░░░░░░░░

░░░░░░░░░░░░░░░░

█████████ *

██▄█████▄██ *

█████████ *

.....................█ █ █ █..............................................................................................................................

Unable to connect to Anthropic services

Failed to connect to api.anthropic.com: ETIMEDOUT

Please check your internet connection and network settings.

Note: Claude Code might not be available in your country. Check supported countries at

https://anthropic.com/supported-countries

3.解决

创建 ~/.claude/settings.json 文件, 需要更换为实际的信息(如下为火山引擎的base_url), 内容如下

复制代码
{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "xxx",
    "ANTHROPIC_BASE_URL": "https://ark.cn-beijing.volces.com/api/coding",
    "API_TIMEOUT_MS": "3000000",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "glm-4.7",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "glm-4.7",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "glm-4.7"
  },
  "skipDangerousModePermissionPrompt": true
}

清理无效会话和环境变量, 若其他地方有设置环境变量需要去除

bash 复制代码
claude /logout
unset ANTHROPIC_AUTH_TOKEN
unset ANTHROPIC_MODEL
相关推荐
码哥字节1 天前
我翻了 Claude Code 的系统提示词,发现 Skill 作者踩了这 5 个坑
claude·mcp
吨吨ai1 天前
# ChatGPT Plus / Pro + Codex Debug 实战:如何让 AI 从日志、Trace、异常堆栈自动定位线上 Bug
人工智能·chatgpt·bug
乘风gg1 天前
9 张 AI 生成的图,吃透任何一个前端项目
前端·ai编程·claude
灰暗世界%2 天前
飞牛bug修复
bug
JavaGuide2 天前
阿里版 Claude Code 实测,表现怎么样?
ai编程·claude
神奇霸王龙2 天前
CC Switch 配置 Claude Desktop+ selltoken 中转 API 实测教程(2026 年 8 月更新)
人工智能·ai·aigc·agent·ai编程·claude
VIP_CQCRE3 天前
Claude 接入 Luma MCP:一句话让 AI 生成电影感短视频
ai·claude·mcp·luma·acedatacloud