# What Is the Request Timeout Configuration for the Dify Plugin?

> Understand the Dify plugin request timeout configuration. Discover how the MAX_REQUEST_TIMEOUT parameter controls query execution time for optimal performance. Learn more now.

- Repository: [Junjie.M/dify-plugin-tools-dbquery](https://github.com/junjiem/dify-plugin-tools-dbquery)
- Tags: how-to-guide
- Published: 2026-03-05

---

**The Dify plugin sets a default request timeout of 120 seconds via the `MAX_REQUEST_TIMEOUT` parameter in the `DifyPluginEnv` configuration.**

Understanding the request timeout configuration for the Dify plugin is essential when working with the `junjiem/dify-plugin-tools-dbquery` repository. This timeout value determines how long the plugin will wait for operations to complete before aborting them, directly impacting database query reliability and user experience.

## Where the Timeout Is Configured

The request timeout is hardcoded in the plugin's entry point files. According to the source code in `junjiem/dify-plugin-tools-dbquery`, the `MAX_REQUEST_TIMEOUT` is set to `120` seconds when initializing the `DifyPluginEnv` class.

In [`db_query/main.py`](https://github.com/junjiem/dify-plugin-tools-dbquery/blob/main/db_query/main.py), the configuration appears as:

```python
from dify_plugin import Plugin, DifyPluginEnv

plugin = Plugin(DifyPluginEnv(MAX_REQUEST_TIMEOUT=120))

if __name__ == '__main__':
    plugin.run()

```

The same configuration exists in [`db_query_pre_auth/main.py`](https://github.com/junjiem/dify-plugin-tools-dbquery/blob/main/db_query_pre_auth/main.py), ensuring consistent timeout behavior across both the standard and pre-authentication modes of the plugin.

## How to Modify the Request Timeout

While the default value is 120 seconds, you can adjust this by changing the `MAX_REQUEST_TIMEOUT` parameter when instantiating the plugin.

To reduce the timeout to 60 seconds for faster failure detection:

```python
plugin = Plugin(DifyPluginEnv(MAX_REQUEST_TIMEOUT=60))

```

To increase the timeout for slower network conditions or complex queries:

```python
plugin = Plugin(DifyPluginEnv(MAX_REQUEST_TIMEOUT=300))

```

**Important:** After modifying the timeout value, you must rebuild and redeploy the plugin, as this configuration is baked into the environment at startup and cannot be changed dynamically at runtime.

## Summary

- The default **request timeout configuration for the Dify plugin** is **120 seconds**.
- This value is defined in [`db_query/main.py`](https://github.com/junjiem/dify-plugin-tools-dbquery/blob/main/db_query/main.py) and [`db_query_pre_auth/main.py`](https://github.com/junjiem/dify-plugin-tools-dbquery/blob/main/db_query_pre_auth/main.py) via `DifyPluginEnv(MAX_REQUEST_TIMEOUT=120)`.
- The timeout applies to the plugin's request handling lifecycle, affecting how long operations can run before termination.
- Modifying the timeout requires changing the source code and redeploying the plugin instance.

## Frequently Asked Questions

### What is the default request timeout for the Dify plugin?

The default request timeout is **120 seconds** (2 minutes). This is set via the `MAX_REQUEST_TIMEOUT=120` parameter in the `DifyPluginEnv` configuration within the plugin's main entry files.

### Where is the request timeout configured in the Dify plugin source code?

The timeout is configured in two locations within the `junjiem/dify-plugin-tools-dbquery` repository: [`db_query/main.py`](https://github.com/junjiem/dify-plugin-tools-dbquery/blob/main/db_query/main.py) and [`db_query_pre_auth/main.py`](https://github.com/junjiem/dify-plugin-tools-dbquery/blob/main/db_query_pre_auth/main.py). Both files instantiate the plugin using `Plugin(DifyPluginEnv(MAX_REQUEST_TIMEOUT=120))`.

### Can I change the request timeout without modifying the source code?

No, the timeout cannot be changed without modifying the source code. The `MAX_REQUEST_TIMEOUT` value is hardcoded in the Python files and baked into the plugin environment at startup. To change it, you must edit the relevant [`main.py`](https://github.com/junjiem/dify-plugin-tools-dbquery/blob/main/main.py) file, set your desired value, and redeploy the plugin.

### Does the timeout apply to database queries or HTTP requests?

The `MAX_REQUEST_TIMEOUT` parameter controls the plugin's overall request handling timeout within the Dify plugin framework. While it governs how long the plugin will process a single request (which includes database query execution time), the specific implementation details depend on how the plugin handles the underlying database connections within that timeout window.