Task runner connection attempt failed with status code 403

Describe the problem/error/question

I’m running n8n in Google Cloud VM using docker-compose and traefik, but I’m not being able to properly work with task runners enabled, every time I get "WARN Found runner unresponsive" and:

error | Task runner connection attempt failed with status code 403 {"file":"task-broker-server.js","function":"response.writeHead"}

And the same error keeps spamming in the logs, and I’m not able to execute any code node.

This only happens when I set N8N_RUNNERS_ENABLED=true

I’ve tried following what others have said in posts like this Self-hosted N8N - Task runner connection attempt failed with status code 403 but haven’t been able to fix it.

What is the error message (if any)?

error | Task runner connection attempt failed with status code 403 {"file":"task-broker-server.js","function":"response.writeHead"}

Please share your workflow

This is my current docker-compose file.

services:
  traefik:
    image: traefik:latest
    restart: always
    command:
      - --api=true
      - --api.insecure=true
      - --providers.docker=true
      - --providers.docker.exposedbydefault=false
      - --entrypoints.web.address=:80
      - --entrypoints.web.http.redirections.entryPoint.to=websecure
      - --entrypoints.web.http.redirections.entrypoint.scheme=https
      - --entrypoints.websecure.address=:443
      - --certificatesresolvers.mytlschallenge.acme.tlschallenge=true
      - --certificatesresolvers.mytlschallenge.acme.email=${SSL_EMAIL}
      - --certificatesresolvers.mytlschallenge.acme.storage=/letsencrypt/acme.json
      - --log.level=DEBUG
      - --accesslog=true
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - traefik_data:/letsencrypt
      - /var/run/docker.sock:/var/run/docker.sock:ro
    networks:
      - n8n-net

  n8n:
    image: docker.n8n.io/n8nio/n8n:latest
    restart: always
    ports:
      - "127.0.0.1:5678:5678"
    labels:
      - traefik.enable=true
      - traefik.http.routers.n8n.rule=Host(`${SUBDOMAIN}.${DOMAIN_NAME}`)
      - traefik.http.routers.n8n.tls=true
      - traefik.http.routers.n8n.entrypoints=web,websecure
      - traefik.http.routers.n8n.tls.certresolver=mytlschallenge
      - traefik.http.routers.n8n.middlewares=n8n@docker
      - traefik.http.middlewares.n8n.headers.SSLRedirect=true
      - traefik.http.middlewares.n8n.headers.STSSeconds=${SECONDS}
      - traefik.http.middlewares.n8n.headers.browserXSSFilter=true
      - traefik.http.middlewares.n8n.headers.contentTypeNosniff=true
      - traefik.http.middlewares.n8n.headers.forceSTSHeader=true
      - traefik.http.middlewares.n8n.headers.SSLHost=${DOMAIN_NAME}
      - traefik.http.middlewares.n8n.headers.STSIncludeSubdomains=true
      - traefik.http.middlewares.n8n.headers.STSPreload=true
    environment:
      # Core
      - N8N_HOST=${SUBDOMAIN}.${DOMAIN_NAME}
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - WEBHOOK_URL=https://${SUBDOMAIN}.${DOMAIN_NAME}/
      - N8N_METRICS=true
      - N8N_ENCRYPTION_KEY=${N8N_ENCRYPTION_KEY}

      # Database
      - DB_TYPE=postgresdb
      - DB_POSTGRESDB_HOST=${DB_POSTGRESDB_HOST_VALUE}
      - DB_POSTGRESDB_PORT=5432
      - DB_POSTGRESDB_DATABASE=${DB_POSTGRESDB_DATABASE_VALUE}
      - DB_POSTGRESDB_USER=${DB_POSTGRESDB_USER_VALUE}
      - DB_POSTGRESDB_PASSWORD=${DB_POSTGRESDB_PASSWORD_VALUE}
      - DB_POSTGRESDB_SCHEMA=${DB_POSTGRESDB_SCHEMA_VALUE}

      # Task runners
      - N8N_RUNNERS_ENABLED=true

      # Permissions & logging
      - N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
      - N8N_LOG_LEVEL=debug

    volumes:
      - n8n_data:/home/node/.n8n
      - ./local-files:/files
    networks:
      - n8n-net

volumes:
  n8n_data:
  traefik_data:

networks:
  n8n-net:
    driver: bridge
(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

  • n8n version: latest
  • Database (default: SQLite): postgres
  • n8n EXECUTIONS_PROCESS setting (default: own, main): main
  • Running n8n via (Docker, npm, n8n cloud, desktop app): docker-compose
  • Operating system: linux

Why do these errors occur?

Setting N8N_RUNNERS_ENABLED=true enables n8n’s parallel task runner system. When this system is enabled:

  • n8n acts as a “broker” (i.e., the main server)
  • It delegates executions to separate runner containers

However, in your docker-compose.yml file, there are no task-runner services defined.
Solution 1: Add runner container(s)
Solution 2: Set N8N_RUNNERS_ENABLED to false

Based on the documentation Task runners | n8n Docs, default n8n task runners are internal (as child processes) if we don’t specify N8N_RUNNERS_MODE=external, so technically there’s no need to define separate runner containers.

And setting N8N_RUNNERS_ENABLED=false fixes the issue, but only temporarily because it’s being deprecated and in the next versions of n8n the standard and only official way of working is with task runners enabled.

Thanks for your reply, and let me know if there is anything else I could try.

You will need to make a runner node, and start n8n with “runner”, see here

there are webhook nodes too,

Workflows Stuck in "Queued" Status After ~60 Seconds of Execution Time - #18 by manishkhanna.

There are some example docker files, with the extra nodes needed, :slight_smile: hope this helps.

@King_Samuel_David The last reply from the original poster already explains that he is not using N8N_RUNNERS_MODE=external. There should not be any need for additional containers when using the default N8N_RUNNERS_MODE=internal setting. Also, the thread to which you linked was related to Queue mode and Workers, not Task Runners. These are two different things.

Ah ofcourse, my bad, need to try out runner mode, not used yet. So do you know why he is getting this issue? "WARN Found runner unresponsive" and error | Task runner connection attempt failed with status code 403 {"file":"task-broker-server.js","function":"response.writeHead"}

:confused: trying to work it out

tried it out by just adding, N8N_RUNNERS_ENABLED=true and running a function in a code node,

/home/node/.n8n/logs # tail -f n8n.log | grep task
{"level":"info","message":"n8n Task Broker ready on 127.0.0.1, port 5679","metadata":{"file":"task-broker-server.js","function":"setupHttpServer","timestamp":"23:45:10.127Z"}}
{"level":"info","message":"Registered runner \"JS Task Runner\" (unry52A4Eudm6MYgAVnRO) ","metadata":{"file":"task-broker-ws-server.js","function":"onMessage","timestamp":"3:45:11.118Z"}}

quite strange am on version 1.91.3 w worker all okay