# HTTP 503 Service Unavailable: Connect REST API is temporarily unavailable due to rebalance

- **ID:** `kafka/connect-rest-api-503-service-unavailable`
- **Domain:** kafka
- **Category:** network_error
- **Error Code:** `503`
- **Verification:** ai_generated
- **Fix Rate:** 79%

## Root Cause

Kafka Connect's REST API returns 503 when the cluster is undergoing a rebalance, as worker leadership may be reassigned and endpoints are temporarily disabled.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Kafka 3.4.0 | active | — | — |
| Kafka 3.5.1 | active | — | — |
| Kafka 3.7.0 | active | — | — |

## Workarounds

1. **Implement retry logic with exponential backoff in your client. Example in Python: import time; for i in range(5): try: response = requests.get('http://connect-host:8083/connectors'); break; except requests.exceptions.HTTPError as e: if e.response.status_code == 503: time.sleep(2**i); else: raise** (93% success)
   ```
   Implement retry logic with exponential backoff in your client. Example in Python: import time; for i in range(5): try: response = requests.get('http://connect-host:8083/connectors'); break; except requests.exceptions.HTTPError as e: if e.response.status_code == 503: time.sleep(2**i); else: raise
   ```
2. **Monitor the rebalance status using Kafka's metrics or logs, and only query the REST API after the rebalance completes. Check for 'REBALANCE_COMPLETED' log entries.** (85% success)
   ```
   Monitor the rebalance status using Kafka's metrics or logs, and only query the REST API after the rebalance completes. Check for 'REBALANCE_COMPLETED' log entries.
   ```

## Dead Ends

- **Setting 'rest.advertised.host.name' to a different value** — Increasing worker timeout does not prevent the 503 during rebalance; the API is intentionally disabled. (90% fail)
- **Restarting a single Connect worker** — Restarting one worker may trigger another rebalance, making the 503 persist longer. (85% fail)
