> For the complete documentation index, see [llms.txt](https://docs.apismart.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apismart.ai/troubleshooting/timeout-and-connection-issues.md).

# Timeout and Connection Issues

Timeout and connection issues occur when your application cannot establish a connection, maintain a request, or receive a response within the expected time.

These issues are usually related to network conditions, client settings, request duration, or temporary service availability.

Before troubleshooting, check:

* Request status in [**Usage Logs and Costs**](/api-usage/usage-logs-and-costs.md)
* HTTP status code
* Error message
* Request time

For general API errors, see [**HTTP Status Codes and API Errors**](/troubleshooting/http-status-codes-and-api-errors.md).

***

### Check Your Network Connection

Before changing your code, verify:

* Your server can access the ApiSmart API endpoint.
* DNS resolution works correctly.
* Your network connection is stable.
* Firewall or security rules are not blocking outbound requests.

Common network-related problems:

* Cannot connect to the API endpoint
* Connection reset
* DNS resolution failure
* SSL/TLS connection error

***

### Check Client Timeout Settings

Your application may stop waiting before ApiSmart finishes processing the request.

Review:

* HTTP client timeout settings
* Proxy or gateway timeout settings
* Serverless function execution limits

For example:

```python
timeout=60
```

may not be enough for requests that require longer processing time.

Increase the timeout according to your application requirements.

***

### Request Timeout

A timeout may occur when:

* The network connection is slow.
* The client timeout is too short.
* The request requires longer processing time.
* The service is temporarily busy.

Recommended actions:

1. Retry the request after a short delay.
2. Check whether the request appears in [**Usage Logs and Costs**](/api-usage/usage-logs-and-costs.md).
3. Confirm whether the request was completed before sending another request.

Avoid sending repeated requests immediately, especially for generation tasks.

***

### Chat, Image, and Video Request Differences

Different API types may have different response times.

#### Chat Completions

Chat requests usually return directly.

If a request takes too long:

Check:

* Input size
* Model selection
* Client timeout settings

***

#### Image Generation

Image generation may require additional processing time.

If the request times out:

Check:

* Whether the request appears in Usage Logs.
* Whether a result was generated.
* Whether the client timed out before receiving the response.

***

#### Video Generation

Video generation is usually an asynchronous workflow.

A request may return a task ID before the video is completed.

Typical flow:

```
Create Video Task
        ↓
Receive Task ID
        ↓
Check Task Status
        ↓
Retrieve Result
```

A long processing time does not always mean the request failed.

Check the task status before submitting another request.

For video-specific issues, see:

[**Video Generation API**](/api-guides/video-generation-api.md)

***

### Connection Reset or Failed Connection

If the connection is interrupted:

Check:

* Network stability
* Firewall rules
* Server outbound access
* Client retry settings

Common causes:

* Temporary network interruption
* Request terminated by the client
* Intermediate proxy or gateway timeout

***

### Temporary Service Errors

Some connection problems may be temporary.

If you receive:

* 502 Bad Gateway
* 503 Service Unavailable
* Connection reset

Try:

1. Wait briefly.
2. Retry the request.
3. Check whether the issue continues.

For repeated failures, save the Request ID and contact support.

***

### Check Usage Logs

When troubleshooting timeout issues:

1. Open **Usage Logs**.

<figure><img src="/files/ZIkcAcnUVNW7HNhkA7Yl" alt=""><figcaption></figcaption></figure>

2. Find the related request.
3. Check:

* Request ID
* Request time
* Model ID
* Status
* Error message
* Cost

This helps determine whether:

* The request reached ApiSmart.
* The request failed before processing.
* The request completed but the client timed out.

***

### Retry Recommendations

When implementing retries:

Recommended:

* Retry temporary failures only.
* Use increasing delays between retries.
* Avoid unlimited retries.

Avoid:

* Repeating failed requests immediately.
* Creating duplicate generation tasks.
* Retrying requests without checking previous status.

***

### When to Contact Support

Contact support if:

* Requests consistently fail after checking your configuration.
* The same Request ID shows unexpected behavior.
* Multiple endpoints fail at the same time.
* Usage Logs do not match your request results.

Include:

* Request ID
* API endpoint
* Model ID
* Request time
* HTTP status code
* Error message

Do not include:

* Full API Token
* Account password
* Payment information

> 🔐 Never provide your full API Token to support.

***

### 🚀 Next Steps

Continue with:

* [**HTTP Status Codes and API Errors**](/troubleshooting/http-status-codes-and-api-errors.md)
* [**API Token and Authentication Issues**](/troubleshooting/api-token-and-authentication-issues.md)
* [**Model and Request Errors**](/troubleshooting/model-and-request-errors.md)
* [**Video Generation API**](/api-guides/video-generation-api.md)
* [**Usage Logs and Costs**](/api-usage/usage-logs-and-costs.md)
