Dify save model provider request timed out when configuring API
Dify hangs on saving a model provider and the browser logs a TimeoutError on the console API. How to isolate the cause and fix it.
The symptom
You open the model provider settings in a self-hosted Dify instance, enter the credentials, and click save. The dialog stays in its saving state indefinitely. Nothing appears in the UI, no validation message, no server error toast. Eventually the browser gives up and the console prints something like:
Uncaught (in promise) TimeoutError: Request timed out: POST http://<your-host>:8080/console/api/workspaces/current/model-providers/<provider>/<model>
The key detail is where the timeout happens: it is the request from your browser to the Dify console API, not a request from Dify to the model vendor. That distinction drives everything below. In the original report the request was to the console API path for a model provider, and the only information available was the browser-side timeout.
Why it happens
Because the failing request is browser to console API, the hang can be in the frontend, the console API container, or the network path between them. Ranked by how cheap they are to check:
1. The console API worker is blocked or slow. If the request reaches the API but the handler never returns, the browser times out first. Confirm by watching the api container logs while you click save; if you see the request arrive but no completion, the problem is server-side.
2. The request never reaches the API. A reverse proxy, firewall, or port mapping in front of port 8080 may be dropping or stalling the POST. Confirm by checking the proxy access log for the same path at the same timestamp; no entry means it never arrived.
3. Outbound egress from the API container is blocked. Saving a provider often triggers a validation call to the vendor. If that call hangs, the handler hangs with it. Confirm by running a curl to the vendor endpoint from inside the api container.
4. A stale or mismatched deployment. Mixed container images or leftover volumes after repeated reinstalls can produce handlers that never respond. Confirm by checking that all containers report the same image tag.
Note that raising GUNICORN_TIMEOUT and restarting Docker were both tried in the thread without success, which weakens cause 1 as the sole explanation but does not rule out causes 2 and 3.
How to fix it
- Reproduce the save with the browser devtools network tab open. Note whether the POST stays pending or fails fast; pending points to a hang, fast failure points to a different problem.
- Tail the api container logs (docker compose logs -f api) in one terminal and click save in the other. If nothing is logged, move to the proxy layer; if a request is logged but never finishes, move to the egress check.
- Check the reverse proxy or load balancer in front of port 8080. Confirm it forwards POST bodies, does not buffer indefinitely, and has a read timeout at least as long as the browser timeout.
- From inside the api container, run a curl against the model vendor base URL you configured. If it hangs, fix egress (DNS, firewall, proxy variables) before touching Dify.
- If the container has HTTP_PROXY or HTTPS_PROXY set but the vendor does not need a proxy, unset them for the api service and restart. The reporter stated their model services do not use a proxy, so an inherited proxy variable is a plausible mismatch.
- Verify all containers run the same image tag and that no old volumes are mounted. Recreate the stack with a clean compose up rather than restarting in place.
- If the save still hangs after all of the above, capture the api container logs plus the exact console URL and open a fresh issue, since the original thread was never resolved.
When this is not the cause
If the browser shows a 4xx or 5xx response instead of a timeout, this is not the hang described here. A 401 or 403 means the credentials or API key were rejected; a 400 usually means a malformed base URL or missing required field. Those are validation failures, not timeouts, and they return quickly.
If the failure happens only when you run a workflow or chat, not when you save the provider, the problem is in the model invocation path rather than provider configuration. Check the model call logs separately.
If the timeout appears on a different console API path, such as workspace or app endpoints, the cause is more likely general API unhealthiness than anything specific to model provider saving.
Finally, if you are on a hosted deployment rather than self-hosted Docker, the network and proxy hypotheses do not apply, and you should look at the platform status and your own outbound access instead.
How to apply this with Admesh
The egress hypothesis above is the most common reason a provider save hangs: the Dify api container cannot reach the vendor endpoint. Pointing Dify at a single OpenAI-compatible gateway removes the per-vendor egress problem, because there is only one host to reach.
In Dify, add a model provider that uses the OpenAI-compatible API type and set the base URL to https://api.admesh.ai/v1. Use one Admesh API key for that provider entry. Because Admesh serves OpenAI, Anthropic, Google, DeepSeek, Qwen, Moonshot, Zhipu, and MiniMax families behind one key and one balance, you do not need a separate provider entry and a separate egress path per vendor.
If you prefer the Anthropic message format, configure the Anthropic-compatible endpoint at https://api.admesh.ai/v1/messages instead. Either way, verify reachability from inside the api container with a curl to the chosen base URL before saving, so a network problem shows up as a network problem rather than a hanging dialog.
Check the model catalog and current pricing at https://admesh.ai/models before choosing model names, and keep the docs at https://docs.admesh.ai and the console at https://console.admesh.ai handy for key and balance checks.
FAQ
FAQ
Does raising GUNICORN_TIMEOUT fix the hanging save?
Is this a known Dify bug with a fix?
How do I tell a network problem from an application problem?
Can I avoid per-vendor connectivity issues entirely?
References
Call these models through one gateway
Admesh provides a unified OpenAI-compatible API: one Base URL and one key for Claude, GPT, DeepSeek and more. New accounts get trial credit that never expires.
