Erro Connection Refused — Conexão Recusada
Como resolver erro de conexão recusada no OpenClaw. Problemas de rede, firewall e configuração.
⏱️ 2 min de leitura
Erro: Connection Refused
O OpenClaw não conseguiu conectar a um serviço. Veja como resolver.
O Que Significa
Error: connect ECONNREFUSED 127.0.0.1:3000
Error: Connection refused to api.anthropic.com
Error: ECONNREFUSED when connecting to webhook
Tentou conectar a um serviço que não está respondendo.
Causas Comuns
1. Serviço Não Está Rodando
# Verificar se gateway está rodando
openclaw gateway status
# Se não estiver, iniciar
openclaw gateway start
2. Porta Errada
# config.yaml - verificar porta
server:
port: 3000 # Deve ser a mesma usada
3. Firewall Bloqueando
# Linux - verificar firewall
sudo ufw status
# Permitir porta
sudo ufw allow 3000
4. API Externa Indisponível
# Testar conectividade
curl -I https://api.anthropic.com
curl -I https://api.openai.com
5. DNS Não Resolvendo
# Testar DNS
nslookup api.anthropic.com
ping api.anthropic.com
Por Cenário
Gateway Não Conecta
# Verificar se porta está em uso
lsof -i :3000
# Matar processo se necessário
kill -9 [PID]
# Reiniciar gateway
openclaw gateway restart
API Anthropic/OpenAI
Verificar status:
Testar conexão:
curl https://api.anthropic.com/v1/messagesVerificar proxy:
echo $HTTP_PROXY echo $HTTPS_PROXY
Webhook Não Recebe
# Verificar se URL está acessível
curl -X POST https://seu-webhook.com/endpoint
# Verificar firewall/NAT
# Se local, usar ngrok para expor
ngrok http 3000
Integração Externa
# Testar endpoint da integração
curl https://api.github.com
curl https://slack.com/api/api.test
Diagnóstico
Verificar Rede
# Testar conectividade geral
ping 8.8.8.8
ping google.com
# Testar DNS
nslookup api.anthropic.com
# Testar porta específica
nc -zv api.anthropic.com 443
Verificar Logs
openclaw logs | grep -i "refused\|ECONNREFUSED\|connect"
Modo Debug
DEBUG=* openclaw gateway start
Soluções Rápidas
Reiniciar Tudo
openclaw gateway stop
sleep 5
openclaw gateway start
Limpar Cache DNS
# macOS
sudo dscacheutil -flushcache
# Linux
sudo systemd-resolve --flush-caches
Verificar VPN/Proxy
Se usa VPN ou proxy corporativo, pode estar bloqueando.
# Temporariamente desativar
unset HTTP_PROXY
unset HTTPS_PROXY
Configuração de Timeout
# config.yaml
timeouts:
connect: 10000 # 10s para conectar
request: 30000 # 30s para resposta
retry:
max_attempts: 3
delay: 1000