---
title: "Erro Connection Refused — Conexão Recusada"
url: "https://openclaw.ia.br/erros/connection-refused/"
markdown_url: "https://openclaw.ia.br/erros/connection-refused.MD"
description: "Como resolver erro de conexão recusada no OpenClaw. Problemas de rede, firewall e configuração."
date: ""
author: ""
---

# Erro Connection Refused — Conexão Recusada

Como resolver erro de conexão recusada no OpenClaw. Problemas de rede, firewall e configuração.


# 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

```bash
# Verificar se gateway está rodando
openclaw gateway status

# Se não estiver, iniciar
openclaw gateway start
```

### 2. Porta Errada

```yaml
# config.yaml - verificar porta
server:
  port: 3000  # Deve ser a mesma usada
```

### 3. Firewall Bloqueando

```bash
# Linux - verificar firewall
sudo ufw status

# Permitir porta
sudo ufw allow 3000
```

### 4. API Externa Indisponível

```bash
# Testar conectividade
curl -I https://api.anthropic.com
curl -I https://api.openai.com
```

### 5. DNS Não Resolvendo

```bash
# Testar DNS
nslookup api.anthropic.com
ping api.anthropic.com
```

## Por Cenário

### Gateway Não Conecta

```bash
# 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

1. **Verificar status:**
   - https://status.anthropic.com
   - https://status.openai.com

2. **Testar conexão:**
   ```bash
   curl https://api.anthropic.com/v1/messages
   ```

3. **Verificar proxy:**
   ```bash
   echo $HTTP_PROXY
   echo $HTTPS_PROXY
   ```

### Webhook Não Recebe

```bash
# 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

```bash
# Testar endpoint da integração
curl https://api.github.com
curl https://slack.com/api/api.test
```

## Diagnóstico

### Verificar Rede

```bash
# 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

```bash
openclaw logs | grep -i "refused\|ECONNREFUSED\|connect"
```

### Modo Debug

```bash
DEBUG=* openclaw gateway start
```

## Soluções Rápidas

### Reiniciar Tudo

```bash
openclaw gateway stop
sleep 5
openclaw gateway start
```

### Limpar Cache DNS

```bash
# macOS
sudo dscacheutil -flushcache

# Linux
sudo systemd-resolve --flush-caches
```

### Verificar VPN/Proxy

Se usa VPN ou proxy corporativo, pode estar bloqueando.

```bash
# Temporariamente desativar
unset HTTP_PROXY
unset HTTPS_PROXY
```

## Configuração de Timeout

```yaml
# config.yaml
timeouts:
  connect: 10000  # 10s para conectar
  request: 30000  # 30s para resposta
  
retry:
  max_attempts: 3
  delay: 1000
```

## Próximos Passos

- [Timeout](/erros/timeout/)
- [Troubleshooting](/troubleshooting/)
- [FAQ Técnico](/faq/tecnico/)
