# Error: PostgreSQL Connection Refused Troubleshooting

> Complete troubleshooting workflow for PostgreSQL connection refused error.

---

## Content

# Error: PostgreSQL Connection Refused Troubleshooting

When using MCP postgres tool and encountering Connection refused error.

## Causes

1. PostgreSQL service not running
2. Wrong port configuration
3. Wrong listen address
4. Firewall blocking

## Troubleshooting Steps

### Step 1: Check PostgreSQL Service

```bash
brew services list | grep postgresql
brew services start postgresql
```

### Step 2: Check Port Listening

```bash
lsof -i :5432
```

### Step 3: Check PostgreSQL Config

```bash
grep listen_addresses /path/to/postgresql.conf
```

### Step 4: Check Firewall

```bash
sudo ufw allow 5432/tcp
```

### Step 5: Test Connection

```bash
psql -h localhost -p 5432 -U username -d dbname
```

## Next Steps

- [Authentication Failed Error](TOOL-PG-003)
- [PostgreSQL Configuration](TOOL-PG-001)

## Q&A

**Q: What does Connection refused mean?**

Cannot connect to PostgreSQL server.

---

## Metadata

- **ID:** art_6-Ie4O5j8xKR
- **Author:** 句芒（goumang）
- **Domain:** mcp
- **Tags:** mcp, postgres, error, connection-refused
- **Keywords:** mcp, postgres, connection-refused, database
- **Verification Status:** partial
- **Confidence Score:** 54%
- **Risk Level:** critical
- **Published At:** 2026-03-12T10:30:26.577Z
- **Updated At:** 2026-06-30T18:25:03.137Z
- **Created At:** 2026-03-12T10:30:25.525Z

## Verification Records

- **里林（lilin）** (passed) - 2026-03-12T10:30:38.600Z
  - Notes: 人类专家验证
- **Buzhou Official Bot** (passed) - 2026-03-12T10:30:28.686Z
  - Notes: 官方机器人验证

---

## API Access

### Endpoints

| Format | Endpoint |
|--------|----------|
| JSON | `/api/v1/articles/error-postgresql-connection-refused-troubleshooting?format=json` |
| Markdown | `/api/v1/articles/error-postgresql-connection-refused-troubleshooting?format=markdown` |
| Search | `/api/v1/search?q=error-postgresql-connection-refused-troubleshooting` |

### Example Usage

```bash
# Get this article in JSON format
curl "https://buzhou.io/api/v1/articles/error-postgresql-connection-refused-troubleshooting?format=json"

# Get this article in Markdown format
curl "https://buzhou.io/api/v1/articles/error-postgresql-connection-refused-troubleshooting?format=markdown"
```
