> ## Documentation Index
> Fetch the complete documentation index at: https://docs.knoxcall.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Troubleshooting 504 Gateway Timeout Errors

> Learn how to diagnose and fix 504 Gateway Timeout errors. Common causes and solutions included.

# Troubleshooting 504 Gateway Timeout

Getting 504 errors? This guide will help you diagnose and fix timeout issues.

## What is a 504 Error?

A 504 Gateway Timeout occurs when KnoxCall doesn't receive a response from your upstream service within the timeout period (default: 30 seconds).

## Common Causes

### 1. Slow Upstream Service

Your backend service is taking too long to respond.

**Solution:**

* Check your backend service logs
* Optimize slow database queries
* Add caching for expensive operations
* Scale your backend infrastructure

### 2. Network Issues

Network connectivity problems between KnoxCall and your backend.

**Solution:**

* Verify your target URL is correct
* Check firewall rules
* Test connectivity: `curl your-backend-url`
* Ensure your backend is accessible from the internet

### 3. Timeout Too Short

The default 30s timeout may be too short for your use case.

**Solution:**

* Contact support to increase timeout limits
* Consider async processing for long-running tasks
* Use webhooks for callbacks instead of long-polling

### 4. Backend Service Down

Your upstream service may be unavailable.

**Solution:**

* Check if your backend is running
* Review your backend service health checks
* Check your hosting provider status page

## Debugging Steps

1. **Check Recent Errors**
   * Go to **Logs** in the dashboard
   * Filter by status code: 504
   * Look for patterns in timing

2. **Test Direct Connection**
   ```bash theme={"dark"}
   curl -v https://your-backend.com/api/endpoint
   ```

3. **Check Alerts**
   * Review any triggered alerts
   * Look for error rate spikes

4. **Review Metrics**
   * Check P95/P99 latency
   * Identify slow endpoints

## Prevention

### Set Up Alerts

Configure alerts for high latency:

* Threshold: P95 > 5 seconds
* Action: Get notified immediately

### Add Health Checks

Implement health check endpoints:

```javascript theme={"dark"}
app.get("/health", (req, res) => {
  res.json({ status: "healthy" });
});
```

### Use Caching

Add caching for frequently accessed data:

* Redis cache
* CDN for static content
* Application-level caching

### Optimize Queries

* Add database indexes
* Use query pagination
* Implement connection pooling

## Still Having Issues?

If you're still experiencing 504 errors:

1. Check the support chat
2. Create a support ticket with:
   * Route name
   * Timestamp of errors
   * Sample requests that fail
3. Contact support for timeout limit increases

***

<CardGroup cols={2}>
  <Card title="📊 Statistics" icon="chart-line">
    * **Views**: 2
    * **Helpful**: 0 👍
    * **Level**: intermediate
  </Card>

  <Card title="🏷️ Tags" icon="tags">
    `errors`, `504`, `timeout`, `debugging`
  </Card>
</CardGroup>
