Python Node not working in my n8n(self-hosted)

Describe the problem/error/question

Hello everyone,

Please help me. I am experiencing an issue with the Python code node runner. I tried using the docs task runner setting for setup, but when I try to run the Python code on my n8n, clicking on ‘Execute Code’ simply loads for a long time. I also tried to follow a youtube tutorial for setting task runner on my Docker n8n client, but it still loads. No error is showing.

I have added my configuration codes that are used to host my Docker n8n client.

This is the tutorial video - https://youtu.be/-kd5YCzAcP8?si=cWavJAZnJrmOcxI0

My Docker Compose file

### YML
services:
  n8n:
    image: n8nio/n8n
    restart: always
    container_name: n8n-server
    ports: 
      - "5678:5678"
      - "5679:5679"
    environment:
      WEBHOOK_URL: 
      N8N_RUNNERS_ENABLE: "true"
      N8N_RUNNERS_MODE: "external"
      N8N_RUNNERS_DISABLED_MODES: "embedded"
      N8N_RUNNERS_JAVASCRIPT_ENABLED: "true"
      N8N_RUNNERS_PYTHON_ENABLED: "true"
      N8N_NATIVE_PYTHON_RUNNER: "true"
      N8N_RUNNERS_BROKER_LISTEN_ADDRESS: "0.0.0.0"
      N8N_RUNNERS_BROKER_PORT: "5679"
      N8N_RUNNERS_AUTH_TOKEN: "helloworld"
    env_file:
      - .env
    volumes:
      - ./n8n-data:/home/node/.n8n


  runner:
    image: custom-n8n-runner
    build:
        context: .
        dockerfile: Dockerfile
    environment:
      N8N_RUNNERS_TASK_BROKER_URI: "http://n8n:5679"
      N8N_RUNNERS_AUTH_TOKEN: "helloworld"
      N8N_RUNNERS_LAUNCHER_LOG_LEVEL: "debug"
    restart: always
    depends_on:
      - n8n

volumes:
   n8n_data:

My dockerfile

FROM n8nio/runners

USER root

RUN cd /opt/runners/task-runner-python && uv pip install --python .venv/bin/python yt-dlp requests
	
COPY n8n-task-runners.json /etc/n8n-task-runners.json

USER runners

My JSON file

{
	"task-runners": [
	{
		"runner-type": "javascript",
		"workdir": "/home/runner",
		"command": "/usr/local/bin/node",
		"args": [
			"--disallow-code-generation-from-strings",
			"--disable-proto=delete",
			"/opt/runners/task-runner-javascript/dist/start.js"
		],
		"health-check-server-port": "5681",
		"allowed-env": [
			"PATH",
			"GENERIC_TIMEZONE",
			"NODE_OPTIONS",
			"N8N_RUNNERS_AUTO_SHUTDOWN_TIMEOUT",
			"N8N_RUNNERS_TASK_TIMEOUT",
			"N8N_RUNNERS_MAX_CONCURRENCY",
			"N8N_SENTRY_DSN",
			"N8N_VERSION",
			"ENVIRONMENT",
			"DEPLOYMENT_NAME",
			"HOME"
		],
		"env-overrides": {
			"NODE_FUNCTION_ALLOW_BUILTIN": "*",
			"NODE_FUNCTION_ALLOW_EXTERNAL": "*",
			"N8N_RUNNERS_HEALTH_CHECK_SERVER_HOST": "0.0.0.0:
		}
	},
	{
		"runner-type": "python",
		"workdir": "/home/runner",
		"command": "/opt/runners/task-runner-python/.venv/bin/python",
		"args": ["-m","src.main"],
		"health-check-server-port": "5682",
		"allowed-env": [
			"PATH",
			"PYTHONPATH",
			"N8N_RUNNERS_LAUNCHER_LOG_LEVEL",
			"N8N_RUNNERS_AUTO_SHUTDOWN_TIMEOUT",
			"N8N_RUNNERS_TASK_TIMEOUT",
			"N8N_RUNNERS_MAX_CONCURRENCY",
			"N8N_SENTRY_DSN",
			"N8N_VERSION",
			"ENVIRONMENT",
			"DEPLOYMENT_NAME",
			"N8N_RUNNERS_STDLIB_ALLOW",
			"N8N_RUNNERS_EXTERNAL_ALLOW"
		],
		"env-overrides": {
			"PYTHONPATH": "/opt/runners/task-runner-python/",
			"N8N_RUNNERS_STDLIB_ALLOW":"*",
			"N8N_RUNNERS_EXTERNAL_ALLOW":"yt-dlp,requests"
		}
	}
	
	]
}

Information on your n8n setup

  • n8n version: 2.1.4
  • Database (default: SQLite): default
  • n8n EXECUTIONS_PROCESS setting (default: own, main): main
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Debian 13

Your json syntax might not be correct, and ensure port 5679 can be reachable between the containers. Make sure everything that needs to be is properly formatted. and make sure your N8N runners health check server host is proeply closed also.

It should be like this - “N8N_RUNNERS_HEALTH_CHECK_SERVER_HOST”: “0.0.0.0”

and

N8N_NATIVE_PYTHON_RUNNER: “true”
N8N_RUNNERS_MODE: “external”
N8N_RUNNERS_DISABLED_MODES: “embedded”

# Remove the first line - Native_python_runner , you cant use external and native at the same time from what I’ve experienced with my n8n self hosted.