TL;DR:
After upgrading to n8n 2.0.2, the Python Code node blocks all imports — including standard library modules (re, urllib) and external packages (bs4).
Running n8n via Docker on an Ubuntu VPS.
Looking for a step-by-step solution to configure permissions or a recommended workaround.
Describe the problem/error/question
After upgrading to n8n 2.0.2, my Python Code node is no longer able to import any modules.
It fails even for standard library imports like re and urllib.parse, and also blocks external packages like bs4.
I run n8n on a Hostinger VPS (Ubuntu) via Docker. This used to work before the upgrade.
I’m looking for a step-by-step guide to enable Python imports in the new sandbox/security model (at least stdlib, and ideally allow specific external packages like beautifulsoup4).
I’m not very experienced with VPS/Docker, so a clear explanation is important.
Also, if this requires a different deployment approach (custom image with packages, config flags/env vars, or a separate Python service), I’d appreciate guidance.
What is the error message (if any)?
Security violations detected
Line 1: Import of external package ‘bs4’ is disallowed. Allowed external packages: none
Line 2: Import of standard library module ‘re’ is disallowed. Allowed stdlib modules: none
Line 3: Import of standard library module ‘urllib.parse’ is disallowed. Allowed stdlib modules: none
Stack trace
Error: Security violations detected
at throwExecutionError (…/n8n-nodes-base/nodes/Code/throw-execution-error.ts:11:9)
at PythonTaskRunnerSandbox.runUsingIncomingItems (…/n8n-nodes-base/nodes/Code/PythonTaskRunnerSandbox.ts:57:30)
at processTicksAndRejections (node:internal/process/task_queues:105:5)
at ExecuteContext.execute (…/n8n-nodes-base/nodes/Code/Code.node.ts:171:12)
at WorkflowExecute.executeNode (…/n8n-core/src/execution-engine/workflow-execute.ts:1045:8)
… (full trace available if needed)
Please share your workflow
Minimal reproduction is a single Python Code node with:
from bs4 import BeautifulSoup
import re
from urllib.parse import urlparse
(full exported workflow JSON available if needed.)
Share the output returned by the last node
No output – node fails immediately with the security violation error above.
Information on your n8n setup
-
n8n version: 2.0.2
-
Database: Not sure (might be default SQLite)
-
n8n EXECUTIONS_PROCESS setting: Not sure (default)
-
Running n8n via: Docker
-
Operating system: Ubuntu (Hostinger VPS)
What I need / questions
-
Is there a supported way in n8n 2.x to allow stdlib imports (e.g.,
re,urllib.parse) in the Python Code node? -
Can I allowlist specific external packages (e.g.,
beautifulsoup4) and how? (env vars / config / docker flags?)
I’m also open to paid hands-on help (remote session) if someone from the community offers consulting, because this is blocking part of my business.
Thanks!