Node code run failed #21263

Closed
opened 2026-02-21 20:11:41 -05:00 by yindo · 10 comments
Owner

Originally created by @OPSTime on GitHub (Dec 24, 2025).

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.11.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Dify Version: 1.11.1
Sandbox Version: 0.2.12

When invoking Dify deployed in Kubernetes via the debug webhook URL of the webhook trigger (https://dify.example.com/triggers/webhook-debug/Od4se00cjGaOpei5dHfdsEFw), the CODE NODE runs normally.
However, when invoking it via the regular webhook URL of the webhook trigger (https://dify.example.com/triggers/webhook/Od4se00cjGaOpei5dHfdsEFw), the CODE NODE fails to run and reports the following error:
Failed to execute code, which is likely a network issue, please check if the sandbox service is running. (Error: [Errno -2] Name or service not known)

Image

✔️ Expected Behavior

success

Actual Behavior

error

Originally created by @OPSTime on GitHub (Dec 24, 2025). ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.11.1 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce Dify Version: 1.11.1 Sandbox Version: 0.2.12 When invoking Dify deployed in Kubernetes via the debug webhook URL of the webhook trigger (https://dify.example.com/triggers/webhook-debug/Od4se00cjGaOpei5dHfdsEFw), the CODE NODE runs normally. However, when invoking it via the regular webhook URL of the webhook trigger (https://dify.example.com/triggers/webhook/Od4se00cjGaOpei5dHfdsEFw), the CODE NODE fails to run and reports the following error: Failed to execute code, which is likely a network issue, please check if the sandbox service is running. (Error: [Errno -2] Name or service not known) <img width="972" height="297" alt="Image" src="https://github.com/user-attachments/assets/5e74183f-481e-459d-8cc4-c932daa7fba3" /> ### ✔️ Expected Behavior success ### ❌ Actual Behavior error
yindo added the 🐞 bug label 2026-02-21 20:11:41 -05:00
yindo closed this issue 2026-02-21 20:11:41 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Dec 24, 2025):

The reason the debug webhook works but the regular webhook fails is that only the regular webhook triggers actual code execution in the sandbox environment. The error [Errno -2] Name or service not known means the Dify app can't resolve the hostname for the sandbox service specified in your CODE_EXECUTION_ENDPOINT setting. This is a DNS/network issue between your Dify app and the sandbox service in your Kubernetes/Docker setup.

To fix this, check that CODE_EXECUTION_ENDPOINT is set to a resolvable hostname or LAN IP from inside the Dify app container/pod. Avoid using localhost or 127.0.0.1—use a Kubernetes service name, cluster IP, or a DNS name that resolves correctly within your cluster. Make sure the sandbox service is running and accessible on the expected port (test with curl or nslookup from the Dify app container). Also, review your Kubernetes service definitions, DNS policies, and network policies to ensure inter-service DNS resolution works as expected.

If you're using Docker Compose, double-check that the sandbox service is on the same network and that ports are mapped correctly. If you have SSRF proxy environment variables set, try setting SSRF_PROXY_HTTP_URL and SSRF_PROXY_HTTPS_URL to empty strings if you suspect proxy issues.

The debug webhook doesn't fail because it doesn't actually execute code in the sandbox—it just simulates the workflow input and dispatches a debug event, so no network call to the sandbox is made.

If you share your current CODE_EXECUTION_ENDPOINT value and relevant network config, I can help review them for issues.

References:

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Dec 24, 2025): <!-- Answer --> The reason the debug webhook works but the regular webhook fails is that only the regular webhook triggers actual code execution in the sandbox environment. The error `[Errno -2] Name or service not known` means the Dify app can't resolve the hostname for the sandbox service specified in your `CODE_EXECUTION_ENDPOINT` setting. This is a DNS/network issue between your Dify app and the sandbox service in your Kubernetes/Docker setup. To fix this, check that `CODE_EXECUTION_ENDPOINT` is set to a resolvable hostname or LAN IP from inside the Dify app container/pod. Avoid using `localhost` or `127.0.0.1`—use a Kubernetes service name, cluster IP, or a DNS name that resolves correctly within your cluster. Make sure the sandbox service is running and accessible on the expected port (test with `curl` or `nslookup` from the Dify app container). Also, review your Kubernetes service definitions, DNS policies, and network policies to ensure inter-service DNS resolution works as expected. If you're using Docker Compose, double-check that the sandbox service is on the same network and that ports are mapped correctly. If you have SSRF proxy environment variables set, try setting `SSRF_PROXY_HTTP_URL` and `SSRF_PROXY_HTTPS_URL` to empty strings if you suspect proxy issues. The debug webhook doesn't fail because it doesn't actually execute code in the sandbox—it just simulates the workflow input and dispatches a debug event, so no network call to the sandbox is made. If you share your current `CODE_EXECUTION_ENDPOINT` value and relevant network config, I can help review them for issues. References: - [Webhook and code execution flow](https://github.com/langgenius/dify/blob/02e0fadef78f0c888b79e7a52ae6714ac73effdc/api/controllers/trigger/webhook.py#L15-L111) - [CODE_EXECUTION_ENDPOINT usage and error handling](https://github.com/langgenius/dify/blob/02e0fadef78f0c888b79e7a52ae6714ac73effdc/api/core/helper/code_executor/code_executor.py#L18-L139) - [Similar DNS/network issues and solutions](https://github.com/langgenius/dify-official-plugins/issues/2318) <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/5c475bf3-725d-475d-84ed-a9d24a67f364?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/5c475bf3-725d-475d-84ed-a9d24a67f364?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/5c475bf3-725d-475d-84ed-a9d24a67f364?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/5c475bf3-725d-475d-84ed-a9d24a67f364?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/5c475bf3-725d-475d-84ed-a9d24a67f364?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/5c475bf3-725d-475d-84ed-a9d24a67f364?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/5c475bf3-725d-475d-84ed-a9d24a67f364?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=The%20reason%20the%20debug%20webhook%20works%20but%20the%20regular%20webhook%20fails%20is%20that%20only%20the%20regular%20webhook%20triggers%20actual%20code%20execution%20in%20the%20sandbox%20environment.%20The%20error%20%60%5BErrno%20-2%5D%20Name%20or%20service%20not%20known%60%20means%20the%20Dify%20app%20can%27t%20resolve%20the%20hostname%20for%20the%20sandbox%20service%20specified%20in%20your%20%60CODE_EXECUTION_ENDPOINT%60%20setting.%20This%20is%20a%20DNS/network%20issue%20between%20your%20Dify%20app%20and%20the%20sandbox%20service%20in%20your%20Kubernetes/Docker%20setup.%0A%0ATo%20fix%20this%2C%20check%20that%20%60CODE_EXECUTION_ENDPOINT%60%20is%20set%20to%20a%20resolvable%20hostname%20or%20LAN%20IP%20from%20inside%20the%20Dify%20app%20container/pod.%20Avoid%20using%20%60localhost%60%20or%20%60127.0.0.1%60%E2%80%94use%20a%20Kubernetes%20service%20name%2C%20cluster%20IP%2C%20or%20a%20DNS%20name%20that%20resolves%20correctly%20within%20your%20cluster.%20Make%20sure%20the%20sandbox%20service%20is%20running%20and%20accessible%20on%20the%20expected%20port%20%28test%20with%20%60curl%60%20or%20%60nslookup%60%20from%20the%20Dify%20app%20container%29.%20Also%2C%20review%20your%20Kubernetes%20service%20definitions%2C%20DNS%20policies%2C%20and%20network%20policies%20to%20ensure%20inter-service%20DNS%20resolution%20works%20as%20expected.%0A%0AIf%20you%27re%20using%20Docker%20Compose%2C%20double-check%20that%20the%20sandbox%20service%20is%20on%20the%20same%20network%20and%20that%20ports%20are%20mapped%20correctly.%20If%20you%20have%20SSRF%20proxy%20environment%20variables%20set%2C%20try%20setting%20%60SSRF_PROXY_HTTP_URL%60%20and%20%60SSRF_PROXY_HTTPS_URL%60%20to%20empty%20strings%20if%20you%20suspect%20proxy%20issues.%0A%0AThe%20debug%20webhook%20doesn%27t%20fail%20because%20it%20doesn%27t%20actually%20execute%20code%20in%20the%20sandbox%E2%80%94it%20just%20simulates%20the%20workflow%20input%20and%20dispatches%20a%20debug%20event%2C%20so%20no%20network%20call%20to%20the%20sandbox%20is%20made.%0A%0AIf%20you%20share%20your%20current%20%60CODE_EXECUTION_ENDPOINT%60%20value%20and%20relevant%20network%20config%2C%20I%20can%20help%20review%20them%20for%20issues.%0A%0AReferences%3A%20%20%0A-%20%5BWebhook%20and%20code%20execution%20flow%5D%28https%3A//github.com/langgenius/dify/blob/02e0fadef78f0c888b79e7a52ae6714ac73effdc/api/controllers/trigger/webhook.py%23L15-L111%29%20%20%0A-%20%5BCODE_EXECUTION_ENDPOINT%20usage%20and%20error%20handling%5D%28https%3A//github.com/langgenius/dify/blob/02e0fadef78f0c888b79e7a52ae6714ac73effdc/api/core/helper/code_executor/code_executor.py%23L18-L139%29%20%20%0A-%20%5BSimilar%20DNS/network%20issues%20and%20solutions%5D%28https%3A//github.com/langgenius/dify-official-plugins/issues/2318%29)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/30118)
Author
Owner

@OPSTime commented on GitHub (Dec 24, 2025):

From the sandbox logs, it appears to be accessible. I also ran curl request tests in the dify-api service container and found that the sandbox can be accessed via the URL configured in the CODE_EXECUTION_ENDPOINT variable:

$ kubectl -n dify get pods dify-api-78d7747684-wzzhl -o yaml | grep -A1 CODE_EXECUTION_ENDPOINT
    - name: CODE_EXECUTION_ENDPOINT
      value: http://dify-sandbox

$ kubectl -n dify exec -it dify-api-78d7747684-wzzhl bash

dify@dify-api-78d7747684-wzzhl:/app/api$ curl -i -XPOST http://dify-sandbox/v1/sandbox/run
HTTP/1.1 401 Unauthorized
Date: Wed, 24 Dec 2025 11:51:18 GMT
Content-Length: 0

dify@dify-api-78d7747684-wzzhl:/app/api$ curl -i http://dev-wisers-dify-sandbox/v1/sandbox/run
HTTP/1.1 404 Not Found
Content-Type: text/plain
Date: Wed, 24 Dec 2025 11:51:24 GMT
Content-Length: 18

Sandbox service logs are as follows:

[GIN] 2025/12/24 - 11:51:18 | 401 | 2.373µs | 10.12.61.150 | POST "/v1/sandbox/run"
[GIN] 2025/12/24 - 11:51:24 | 404 | 449ns | 10.12.61.150 | GET "/v1/sandbox/run"
@OPSTime commented on GitHub (Dec 24, 2025): **From the sandbox logs, it appears to be accessible. I also ran curl request tests in the dify-api service container and found that the sandbox can be accessed via the URL configured in the CODE_EXECUTION_ENDPOINT variable:** ``` $ kubectl -n dify get pods dify-api-78d7747684-wzzhl -o yaml | grep -A1 CODE_EXECUTION_ENDPOINT - name: CODE_EXECUTION_ENDPOINT value: http://dify-sandbox $ kubectl -n dify exec -it dify-api-78d7747684-wzzhl bash dify@dify-api-78d7747684-wzzhl:/app/api$ curl -i -XPOST http://dify-sandbox/v1/sandbox/run HTTP/1.1 401 Unauthorized Date: Wed, 24 Dec 2025 11:51:18 GMT Content-Length: 0 dify@dify-api-78d7747684-wzzhl:/app/api$ curl -i http://dev-wisers-dify-sandbox/v1/sandbox/run HTTP/1.1 404 Not Found Content-Type: text/plain Date: Wed, 24 Dec 2025 11:51:24 GMT Content-Length: 18 ``` **Sandbox service logs are as follows:** ``` [GIN] 2025/12/24 - 11:51:18 | 401 | 2.373µs | 10.12.61.150 | POST "/v1/sandbox/run" [GIN] 2025/12/24 - 11:51:24 | 404 | 449ns | 10.12.61.150 | GET "/v1/sandbox/run" ```
Author
Owner

@dosubot[bot] commented on GitHub (Dec 24, 2025):

Your curl tests confirm that the sandbox service is reachable and DNS resolution works from the dify-api container, but the 401 Unauthorized response means authentication is missing or incorrect. The Dify app sends an X-Api-Key header (from the CODE_EXECUTION_API_KEY env variable) when invoking the sandbox; manual curl tests without this header will always get 401, so they don't fully replicate the app's code execution context (source).

To verify full connectivity and authentication, try this from inside the dify-api container (replace the API key and payload as needed):

curl -X POST http://dify-sandbox/v1/sandbox/run \
  -H "X-Api-Key: <your CODE_EXECUTION_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{"language":"python3","code":"print(1)","preload":""}'

If this returns 200, authentication is working. If you get 401, check that the CODE_EXECUTION_API_KEY in your dify-api container matches the key in the sandbox's config.yaml (source). If you get a DNS error, double-check that CODE_EXECUTION_ENDPOINT uses the correct, resolvable service name and port, and that all relevant pods are on the same Kubernetes network.

If the '[Errno -2] Name or service not known' error still appears in Dify logs when triggering code execution via the regular webhook, please provide any extra error logs. If authentication and network checks pass but the DNS error persists, investigate Kubernetes DNS policies, service discovery, and possible differences in environment or network context between manual and automated execution (source). Restarting pods after config changes can help ensure settings are applied.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Dec 24, 2025): <!-- Answer --> Your curl tests confirm that the sandbox service is reachable and DNS resolution works from the dify-api container, but the 401 Unauthorized response means authentication is missing or incorrect. The Dify app sends an X-Api-Key header (from the CODE_EXECUTION_API_KEY env variable) when invoking the sandbox; manual curl tests without this header will always get 401, so they don't fully replicate the app's code execution context ([source](https://github.com/langgenius/dify/blob/02e0fadef78f0c888b79e7a52ae6714ac73effdc/api/core/helper/code_executor/code_executor.py#L49-L124)). To verify full connectivity and authentication, try this from inside the dify-api container (replace the API key and payload as needed): ```bash curl -X POST http://dify-sandbox/v1/sandbox/run \ -H "X-Api-Key: <your CODE_EXECUTION_API_KEY>" \ -H "Content-Type: application/json" \ -d '{"language":"python3","code":"print(1)","preload":""}' ``` If this returns 200, authentication is working. If you get 401, check that the CODE_EXECUTION_API_KEY in your dify-api container matches the key in the sandbox's config.yaml ([source](https://github.com/langgenius/dify/issues/26652)). If you get a DNS error, double-check that CODE_EXECUTION_ENDPOINT uses the correct, resolvable service name and port, and that all relevant pods are on the same Kubernetes network. If the '[Errno -2] Name or service not known' error still appears in Dify logs when triggering code execution via the regular webhook, please provide any extra error logs. If authentication and network checks pass but the DNS error persists, investigate Kubernetes DNS policies, service discovery, and possible differences in environment or network context between manual and automated execution ([source](https://github.com/langgenius/dify/issues/30014)). Restarting pods after config changes can help ensure settings are applied. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/8ff39b0e-0a7a-4144-89d2-7bd2c2111913?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/8ff39b0e-0a7a-4144-89d2-7bd2c2111913?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/8ff39b0e-0a7a-4144-89d2-7bd2c2111913?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/8ff39b0e-0a7a-4144-89d2-7bd2c2111913?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/8ff39b0e-0a7a-4144-89d2-7bd2c2111913?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/8ff39b0e-0a7a-4144-89d2-7bd2c2111913?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/8ff39b0e-0a7a-4144-89d2-7bd2c2111913?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=Your%20curl%20tests%20confirm%20that%20the%20sandbox%20service%20is%20reachable%20and%20DNS%20resolution%20works%20from%20the%20dify-api%20container%2C%20but%20the%20401%20Unauthorized%20response%20means%20authentication%20is%20missing%20or%20incorrect.%20The%20Dify%20app%20sends%20an%20X-Api-Key%20header%20%28from%20the%20CODE_EXECUTION_API_KEY%20env%20variable%29%20when%20invoking%20the%20sandbox%3B%20manual%20curl%20tests%20without%20this%20header%20will%20always%20get%20401%2C%20so%20they%20don%27t%20fully%20replicate%20the%20app%27s%20code%20execution%20context%20%28%5Bsource%5D%28https%3A//github.com/langgenius/dify/blob/02e0fadef78f0c888b79e7a52ae6714ac73effdc/api/core/helper/code_executor/code_executor.py%23L49-L124%29%29.%0A%0ATo%20verify%20full%20connectivity%20and%20authentication%2C%20try%20this%20from%20inside%20the%20dify-api%20container%20%28replace%20the%20API%20key%20and%20payload%20as%20needed%29%3A%0A%0A%60%60%60bash%0Acurl%20-X%20POST%20http%3A//dify-sandbox/v1/sandbox/run%20%5C%0A%20%20-H%20%22X-Api-Key%3A%20%3Cyour%20CODE_EXECUTION_API_KEY%3E%22%20%5C%0A%20%20-H%20%22Content-Type%3A%20application/json%22%20%5C%0A%20%20-d%20%27%7B%22language%22%3A%22python3%22%2C%22code%22%3A%22print%281%29%22%2C%22preload%22%3A%22%22%7D%27%0A%60%60%60%0A%0AIf%20this%20returns%20200%2C%20authentication%20is%20working.%20If%20you%20get%20401%2C%20check%20that%20the%20CODE_EXECUTION_API_KEY%20in%20your%20dify-api%20container%20matches%20the%20key%20in%20the%20sandbox%27s%20config.yaml%20%28%5Bsource%5D%28https%3A//github.com/langgenius/dify/issues/26652%29%29.%20If%20you%20get%20a%20DNS%20error%2C%20double-check%20that%20CODE_EXECUTION_ENDPOINT%20uses%20the%20correct%2C%20resolvable%20service%20name%20and%20port%2C%20and%20that%20all%20relevant%20pods%20are%20on%20the%20same%20Kubernetes%20network.%0A%0AIf%20the%20%27%5BErrno%20-2%5D%20Name%20or%20service%20not%20known%27%20error%20still%20appears%20in%20Dify%20logs%20when%20triggering%20code%20execution%20via%20the%20regular%20webhook%2C%20please%20provide%20any%20extra%20error%20logs.%20If%20authentication%20and%20network%20checks%20pass%20but%20the%20DNS%20error%20persists%2C%20investigate%20Kubernetes%20DNS%20policies%2C%20service%20discovery%2C%20and%20possible%20differences%20in%20environment%20or%20network%20context%20between%20manual%20and%20automated%20execution%20%28%5Bsource%5D%28https%3A//github.com/langgenius/dify/issues/30014%29%29.%20Restarting%20pods%20after%20config%20changes%20can%20help%20ensure%20settings%20are%20applied.)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/30118)
Author
Owner

@OPSTime commented on GitHub (Dec 24, 2025):

@dosu

The curl command test returned a normal response:

dify@dify-api-78d7747684-wzzhl:/app/api$ curl -i -X POST ${CODE_EXECUTION_ENDPOINT}/v1/sandbox/run   -H "X-Api-Key: ${CODE_EXECUTION_API_KEY}"   -H "Content-Type: application/json"   -d '{"language":"python3","code":"print(1)","preload":""}'
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Date: Wed, 24 Dec 2025 12:09:12 GMT
Content-Length: 65

{"code":0,"message":"success","data":{"error":"","stdout":"1\n"}}
@OPSTime commented on GitHub (Dec 24, 2025): @dosu The curl command test returned a normal response: ``` dify@dify-api-78d7747684-wzzhl:/app/api$ curl -i -X POST ${CODE_EXECUTION_ENDPOINT}/v1/sandbox/run -H "X-Api-Key: ${CODE_EXECUTION_API_KEY}" -H "Content-Type: application/json" -d '{"language":"python3","code":"print(1)","preload":""}' HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8 Date: Wed, 24 Dec 2025 12:09:12 GMT Content-Length: 65 {"code":0,"message":"success","data":{"error":"","stdout":"1\n"}} ```
Author
Owner

@dosubot[bot] commented on GitHub (Dec 24, 2025):

Your successful curl test from the API container confirms that the sandbox is reachable and authentication works in that container. However, when you trigger code execution via the regular webhook, it actually runs in the Celery worker pod/container, which may have different DNS or network visibility. This is a common cause of issues where manual tests succeed but workflow-triggered code execution fails with DNS errors like [Errno -2] Name or service not known (source).

To troubleshoot, run the same curl test (with the correct CODE_EXECUTION_ENDPOINT and CODE_EXECUTION_API_KEY) from inside your worker pod/container. If you see a DNS error there, it confirms the worker can't resolve the sandbox service. Also, compare environment variables and network settings between your API and worker pods, and check for any Kubernetes network policies or DNS settings that might affect only the worker. Reviewing the worker logs at the time of the error can also help pinpoint the issue.

If everything looks correct but the problem persists, check for custom security contexts or pod-level overrides that could affect only the worker's network access.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Dec 24, 2025): <!-- Answer --> Your successful curl test from the API container confirms that the sandbox is reachable and authentication works in that container. However, when you trigger code execution via the regular webhook, it actually runs in the Celery worker pod/container, which may have different DNS or network visibility. This is a common cause of issues where manual tests succeed but workflow-triggered code execution fails with DNS errors like `[Errno -2] Name or service not known` ([source](https://github.com/langgenius/dify/issues/28171#issuecomment-3530385798)). To troubleshoot, run the same curl test (with the correct CODE_EXECUTION_ENDPOINT and CODE_EXECUTION_API_KEY) from inside your worker pod/container. If you see a DNS error there, it confirms the worker can't resolve the sandbox service. Also, compare environment variables and network settings between your API and worker pods, and check for any Kubernetes network policies or DNS settings that might affect only the worker. Reviewing the worker logs at the time of the error can also help pinpoint the issue. If everything looks correct but the problem persists, check for custom security contexts or pod-level overrides that could affect only the worker's network access. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/4c945009-fc99-4aa7-b217-94f6c5429cda?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/4c945009-fc99-4aa7-b217-94f6c5429cda?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/4c945009-fc99-4aa7-b217-94f6c5429cda?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/4c945009-fc99-4aa7-b217-94f6c5429cda?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/4c945009-fc99-4aa7-b217-94f6c5429cda?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/4c945009-fc99-4aa7-b217-94f6c5429cda?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/4c945009-fc99-4aa7-b217-94f6c5429cda?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=Your%20successful%20curl%20test%20from%20the%20API%20container%20confirms%20that%20the%20sandbox%20is%20reachable%20and%20authentication%20works%20in%20that%20container.%20However%2C%20when%20you%20trigger%20code%20execution%20via%20the%20regular%20webhook%2C%20it%20actually%20runs%20in%20the%20Celery%20worker%20pod/container%2C%20which%20may%20have%20different%20DNS%20or%20network%20visibility.%20This%20is%20a%20common%20cause%20of%20issues%20where%20manual%20tests%20succeed%20but%20workflow-triggered%20code%20execution%20fails%20with%20DNS%20errors%20like%20%60%5BErrno%20-2%5D%20Name%20or%20service%20not%20known%60%20%28%5Bsource%5D%28https%3A//github.com/langgenius/dify/issues/28171%23issuecomment-3530385798%29%29.%0A%0ATo%20troubleshoot%2C%20run%20the%20same%20curl%20test%20%28with%20the%20correct%20CODE_EXECUTION_ENDPOINT%20and%20CODE_EXECUTION_API_KEY%29%20from%20inside%20your%20worker%20pod/container.%20If%20you%20see%20a%20DNS%20error%20there%2C%20it%20confirms%20the%20worker%20can%27t%20resolve%20the%20sandbox%20service.%20Also%2C%20compare%20environment%20variables%20and%20network%20settings%20between%20your%20API%20and%20worker%20pods%2C%20and%20check%20for%20any%20Kubernetes%20network%20policies%20or%20DNS%20settings%20that%20might%20affect%20only%20the%20worker.%20Reviewing%20the%20worker%20logs%20at%20the%20time%20of%20the%20error%20can%20also%20help%20pinpoint%20the%20issue.%20%0A%0AIf%20everything%20looks%20correct%20but%20the%20problem%20persists%2C%20check%20for%20custom%20security%20contexts%20or%20pod-level%20overrides%20that%20could%20affect%20only%20the%20worker%27s%20network%20access.)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/30118)
Author
Owner

@OPSTime commented on GitHub (Dec 24, 2025):

Should the same curl test be run inside the dify-worker container for testing?

@OPSTime commented on GitHub (Dec 24, 2025): Should the same curl test be run inside the dify-worker container for testing?
Author
Owner

@OPSTime commented on GitHub (Dec 24, 2025):

@dosu

dify-worker/dify-worker-beat container does not find CODE_EXECUTION_ENDPOINT, CODE_EXECUTION_API_KEY variable configuration:

dify@dify-worker-78867cbbc7-g4l2d:/app/api$ env|grep CODE_EXECUTION

dify@dify-worker-beat-b67664dcf-2brfb:/app/api$ env|grep CODE_EXECUTION

@OPSTime commented on GitHub (Dec 24, 2025): @dosu dify-worker/dify-worker-beat container does not find CODE_EXECUTION_ENDPOINT, CODE_EXECUTION_API_KEY variable configuration: `dify@dify-worker-78867cbbc7-g4l2d:/app/api$ env|grep CODE_EXECUTION` `dify@dify-worker-beat-b67664dcf-2brfb:/app/api$ env|grep CODE_EXECUTION`
Author
Owner

@fatelei commented on GitHub (Dec 24, 2025):

this you k8s dns issue

@fatelei commented on GitHub (Dec 24, 2025): this you k8s dns issue
Author
Owner

@hjlarry commented on GitHub (Dec 24, 2025):

Should the same curl test be run inside the dify-worker container for testing?

add the env CODE_EXECUTION * on your worker container, the webhook runs on the api container when you debug, runs on the worker container when you published

@hjlarry commented on GitHub (Dec 24, 2025): > Should the same curl test be run inside the dify-worker container for testing? add the env `CODE_EXECUTION *` on your worker container, the webhook runs on the api container when you debug, runs on the worker container when you published
Author
Owner

@OPSTime commented on GitHub (Dec 25, 2025):

Thx
The issue with the douban/dify repository's chart is that the CODE_EXECUTION_ENDPOINT and CODE_EXECUTION_API_KEY variables are not configured in the dify-worker and dify-worker-beat services, resulting in

@OPSTime commented on GitHub (Dec 25, 2025): Thx The issue with the douban/dify repository's chart is that the CODE_EXECUTION_ENDPOINT and CODE_EXECUTION_API_KEY variables are not configured in the dify-worker and dify-worker-beat services, resulting in
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#21263