`claude` crashes when the Anthropic API is down

Resolved 💬 5 comments Opened May 14, 2025 by piscisaureus Closed Nov 30, 2025

Environment

  • Claude CLI version: 0.2.114 (Claude Code)
  • Operating System: Linux funk 6.14.2-401.asahi.fc42.aarch64+16k #1 SMP PREEMPT_DYNAMIC Wed Apr 16 12:06:15 UTC * 2025 aarch64 GNU/Linux
  • Terminal: Terminal App (OS X) via ssh

Bug Description

The anthropic API seems more down than anything these days, which is a problem in itself.

This bug is about how the Claude Code CLI deals with it: sometimes it retries, but very often it just exits, losing my queued prompts in the process.

╭───────────────────────────────────────────────────╮
│ ✻ Welcome to Claude Code research preview!        │
│                                                   │
│   /help for help, /status for your current setup  │
│                                                   │
│   cwd: /home/piscisaureus/wrk                     │
╰───────────────────────────────────────────────────╯

 Tips for getting started:

 1. Run /init to create a CLAUDE.md file with instructions for Claude
 2. Use Claude to help with file analysis, editing, bash commands and git
 3. Be as specific as you would with another engineer for the best results

> Help me out
  ⎿  API Error (Connection error.) · Retrying in 1 seconds… (attempt 1/10)
    ⎿  FetchError (request to https://api.anthropic.com/v1/messages?beta=true failed, reason: read ECONNRESET) (ECONNRESET)
  ⎿  API Error (502 <html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
<hr><center>cloudflare</center>
</body>
</html>
) · Retrying in 1 seconds… (attempt 2/10)

✢ Thinking… (57s · ↑ 0 tokens · esc to interrupt)

╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ >                                                                                                                                                                                                        │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

* Thinking… (57s · ↑ 0 tokens · esc to interrupt)

╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ >                                                                                                                                                                                                        │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
  ? for shortcuts



Total cost:            $0.0008
Total duration (API):  3.1s
Total duration (wall): 59.4s
Total code changes:    0 lines added, 0 lines removed
Token usage by model:
    claude-3-5-haiku:  589 input, 77 output, 0 cache read, 0 cache write

View original on GitHub ↗

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