> ## Content Index
> Fetch the complete content index at: https://www.sakashita.page/llms.txt
> Use this file to discover other available public pages before exploring further.

# Claude Code: API Error: Unable to connect to API (ConnectionRefused)
- URL: https://www.sakashita.page/claude-code-api-error-unable-to-connect-to-api-connectionrefused/
- Published: 2026-07-18T01:00:10.000Z
- Updated: 2026-07-22T20:09:48.000Z
- Author: Sakashita Yasunobu
- Tags: 技術

先日Claude Codeをｲｼﾞｲｼﾞしていたら、前触れもなく`API Error: Unable to connect to API (ConnectionRefused)`とかいう謎のエラーをはいてうんともすんとも言わなくなった。

イヤー困った。

> [Unable to connect to API (ConnectionRefused)](https://www.reddit.com/r/ClaudeCode/comments/1r9d6oe/unable%5Fto%5Fconnect%5Fto%5Fapi%5Fconnectionrefused/)  
> by [u/Pristine\_Ad9316](https://www.reddit.com/user/Pristine%5FAd9316/) in [ClaudeCode](https://www.reddit.com/r/ClaudeCode/) 

Redditを見るとDNSを見ろとのこと。

curlでAnthropicのAPIエンドポイントをたたくと確かにDNS周りでなんだか不穏な様子。

`/etc/resolv.conf`を書き換えろと言われるが、なんとも強引すぎやしないかと思い、そっ閉じ。

ダメもとで`sudo shutdown -h now`でお茶を濁したところなんと解決しましたとさ。