What This Workflow Does
This workflow prevents multiple runs of the same process at the same time in n8n.
It uses Redis to check if a lock exists, block new runs if needed, and release the lock when done.
This stops data problems caused by overlapping workflow triggers.
Who Should Use This Workflow
People running workflows that must not run more than once at a time.
Users with processes that update orders or inventory and need to avoid errors from racing runs.
This is good for automations that may start again before finishing.
Tools and Services Used
- n8n: For workflow automation and orchestration.
- Redis: Stores locking keys and states with expiry times.
- Execute Workflow Trigger node: Receives external commands to control lock actions.
- Switch node: Routes execution by action type (get, set, unset).
- If node: Checks if lock exists before proceeding.
- Stop and Error node: Stops execution with error if lock found.
- Wait node: Simulates long steps and state changes.
Inputs, Processing Steps, and Outputs
Inputs
- Action: Controls lock step (get, set, unset).
- Key: Unique identifier for the workflow instance.
- Value: Lock status text like “working” or stage names.
- Timeout: Lock expiry time in seconds.
Processing Steps
- Check Redis if key exists (get action).
- If key exists, stop the workflow with an error.
- If key missing, set the lock key with value and timeout.
- Run workflow steps simulating progress states (started, loading, finishing).
- Unset the lock key to free for future runs.
Outputs
- Either error indicating workflow is running, or normal successful run with lock progress.
- Redis keys track workflow status for visibility and debugging.
Beginner Step-by-Step: How to Use This Workflow in n8n
Importing the Workflow
- Download the workflow JSON file using the Download button on this page.
- Open your n8n editor and select “Import from File”.
- Choose the downloaded file to load the workflow into n8n.
Configuring Credentials and Settings
- Add your Redis credentials inside n8n under Settings → Credentials.
- Check if any node requires updating IDs, emails, or channels and change as needed.
- Review the Set Timeout node to adjust the lock timeout (default 600 seconds) if needed.
Testing and Activating
- Run the workflow manually once to make sure locking and unlocking works as expected.
- If successful, activate the workflow to let it run automatically or triggered by your events.
- Monitor executions in n8n logs and Redis keys using CLI or dashboard.
This method works well whether using cloud or self-host n8n setups.
Customization Ideas
- Change the timeout value in Set Timeout to fit your workflow’s longest run time.
- Add workflow names or IDs inside Redis keys for better tracking when many workflows use this lock system.
- Extend status values to include more detailed progress states like “started”, “loading”, “finishing”.
- Modify Stop and Error node messages to notify users via Slack or email.
- Use different Redis keys to separate locks for different workflow processes.
Edge Cases and Troubleshooting
- Redis Connection Errors: Check credentials and network access if nodes fail to connect.
- Lock Not Releasing: Make sure Unset Key node always runs; use TTL as a fallback.
- Workflow Always Shows “Already Executing”: Verify lock key expiry and proper unlock logic.
Use Redis CLI commands to inspect keys directly to debug locks.
Summary
✓ Prevent multiple runs to avoid data errors.
✓ Use Redis keys with TTL as workflow locks.
✓ Automatically stop new runs if a process is running.
→ Clear status tracking of workflow steps.
→ Save time fixing overlapping execution problems.
