{"record":{"id":"ddfee04e38ed97c0","repo":"n8n-io/n8n","slug":"port-must-be-between-0-and-65535-got-port","errorCode":null,"errorMessage":"Port must be between 0 and 65535, got {port}","messagePattern":"Port must be between 0 and 65535, got (.+?)","errorType":"validation","errorClass":"ConfigurationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/task-runner-python/src/config/health_check_config.py","lineNumber":26,"sourceCode":"    ENV_HEALTH_CHECK_SERVER_ENABLED,\n    ENV_HEALTH_CHECK_SERVER_HOST,\n    ENV_HEALTH_CHECK_SERVER_PORT,\n)\n\n\n@dataclass\nclass HealthCheckConfig:\n    enabled: bool\n    host: str\n    port: int\n\n    @classmethod\n    def from_env(cls):\n        port = read_int_env(\n            ENV_HEALTH_CHECK_SERVER_PORT, DEFAULT_HEALTH_CHECK_SERVER_PORT\n        )\n        if port < 0 or port > 65535:\n            raise ConfigurationError(f\"Port must be between 0 and 65535, got {port}\")\n\n        return cls(\n            enabled=read_bool_env(ENV_HEALTH_CHECK_SERVER_ENABLED, default=False),\n            host=read_str_env(\n                ENV_HEALTH_CHECK_SERVER_HOST, DEFAULT_HEALTH_CHECK_SERVER_HOST\n            ),\n            port=port,\n        )\n","sourceCodeStart":8,"sourceCodeEnd":35,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/task-runner-python/src/config/health_check_config.py#L8-L35","documentation":"Thrown by HealthCheckConfig.from_env when the health check server port read from the N8N_RUNNERS_HEALTH_CHECK_SERVER_PORT environment variable is outside the valid TCP port range [0, 65535]. This is a startup-time configuration validation that prevents the runner from attempting to bind to an impossible port.","triggerScenarios":"The environment variable ENV_HEALTH_CHECK_SERVER_PORT is set to a negative number, a number greater than 65535, or a value that read_int_env parses to an out-of-range integer. The check `port < 0 or port > 65535` fires in the from_env classmethod before the HealthCheckConfig dataclass is constructed.","commonSituations":"Setting the port to a value like 70000 or -1 in a Docker compose file or Kubernetes manifest. Copying a config from a different system that uses a different port scheme. Accidentally setting the variable to a PID or other unrelated number.","solutions":["Set N8N_RUNNERS_HEALTH_CHECK_SERVER_PORT to a value between 0 and 65535 (commonly 1024-65535 for non-privileged).","If you want an OS-assigned port, use 0 (the OS will pick an available port at bind time).","Verify the value is not being overridden by a stray environment variable in your deployment config.","Check for typos or accidental truncation in the port value."],"exampleFix":"# before\nexport N8N_RUNNERS_HEALTH_CHECK_SERVER_PORT=70000\n# after\nexport N8N_RUNNERS_HEALTH_CHECK_SERVER_PORT=8080","handlingStrategy":"validation","validationCode":"import os\n\nport = int(os.environ.get('N8N_RUNNERS_HEALTH_CHECK_SERVER_PORT', '0'))\nif not (0 <= port <= 65535):\n    raise ValueError(f'Port must be 0-65535, got {port}')","typeGuard":null,"tryCatchPattern":"from config.task_runner_config import ConfigurationError\n\ntry:\n    config = HealthCheckConfig.from_env()\nexcept ConfigurationError as e:\n    print(f'Configuration error: {e}')\n    sys.exit(1)","preventionTips":["Validate port values in deployment scripts before applying them.","Use established port ranges (1024-65535) for application-level services.","Document required port ranges in deployment guides."],"tags":["task-runner","python","configuration","port","health-check"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}