n8n on macOS – fix EACCES: permission denied, mkdir ‘/usr/local/lib/node_modules/n8n’

Step by Step Guide to solve n8n macOS Installation Errors

 

Who this is for: Developers and DevOps engineers installing n8n on macOS (Intel or Apple Silicon) who encounter Homebrew permission, architecture, or macOS security errors. We cover this in detail in the n8n Installation Errors Guide

Quick Diagnosis

If brew install n8n aborts with “Permission denied” or “unsupported architecture” on macOS 12+:

# 1️⃣ Give Homebrew write access to its prefix
sudo chown -R $(whoami) $(brew --prefix)/*

# 2️⃣ Install Rosetta 2 (Apple Silicon only)
softwareupdate --install-rosetta --agree-to-license

# 3️⃣ Re‑install n8n with the proper architecture flag
arch -$(uname -m) brew install n8n   # use `arch -x86_64` on M1/M2 for Intel binaries

Start n8n:

n8n start

If the service still fails, continue reading for deeper diagnostics and production‑grade fixes.

1. Prerequisites – What the Installer Expects

If you encounter any docker installation error n8n resolve them before continuing with the setup.

Requirement macOS Intel (x86_64) macOS Apple Silicon (arm64)
Homebrew location /usr/local /opt/homebrew
Xcode Command‑Line Tools xcode-select –install Same
Rosetta 2 (Apple Silicon only) N/A softwareupdate –install-rosetta
Node.js version ≥ 14 (LTS) Same

EEFA note: In production pin Node to an LTS version (brew install node@18) and use npm ci with a lockfile for reproducible builds.

2. Homebrew Install Failures – Common Errors & Fixes

If you encounter any npm installation failure n8n resolve them before continuing with the setup.

2.1 “Permission denied” / “Operation not permitted”

Symptom

Error: Permission denied – /opt/homebrew/Cellar/n8n

Cause – Homebrew’s prefix is owned by root (often after a system upgrade).

Fix

# Change ownership to your user
sudo chown -R $(whoami) $(brew --prefix)/*
# Verify the health of Homebrew
brew doctor   # should report “Your Homebrew is ready to brew.”

2.2 SSL/TLS download errors

Symptom

curl: (35) SSL connect error

Fix

# Refresh Homebrew’s CA bundle
brew reinstall curl-ca-bundle
# Force a fresh n8n download
brew reinstall n8n --force

2.3 “Unsupported architecture”

Symptom

Error: n8n: unsupported architecture (arm64)

Fix – install the Intel‑compatible formula via Rosetta

# Open a temporary x86_64 shell
arch -x86_64 /bin/bash
# Inside that shell, reinstall n8n
brew reinstall n8n
# Return to the native arm64 shell
exit

EEFA warning: Running the entire Homebrew stack under Rosetta can degrade performance. Use Rosetta only for the n8n formula; keep the rest native.

3. macOS Security Restrictions – Gatekeeper & Quarantine

3.1 “n8n cannot be opened because the developer cannot be verified”

macOS tags Homebrew binaries with the com.apple.quarantine attribute, which Gatekeeper blocks.

Resolution

# Remove the quarantine flag from the n8n binary
xattr -d com.apple.quarantine $(brew --prefix)/bin/n8n
# Verify removal (no com.apple.quarantine listed)
xattr -l $(brew --prefix)/bin/n8n

3.2 SIP‑related write errors

If n8n cannot write to /usr/local/var:

  1. Do not disable SIP – it protects the OS.
  2. Redirect n8n’s data folder to a user‑writable location:
export N8N_DATA_FOLDER=$HOME/.n8n
n8n start
# Persist the export in your shell profile
echo 'export N8N_DATA_FOLDER=$HOME/.n8n' >> ~/.zshrc   # or ~/.bash_profile

4. Apple Silicon Compatibility – Step‑by‑Step Guide

4.1 Verify your hardware architecture

uname -m   # arm64 on M1/M2, x86_64 on Intel

4.2 Install Rosetta 2 (if any npm dependency lacks arm64 wheels)

softwareupdate --install-rosetta --agree-to-license

4.3 Force Homebrew to use the correct architecture

Desired binary Command
Native arm64 (preferred) arch -arm64 brew install n8n
Intel x86_64 fallback arch -x86_64 brew install n8n

4.4 Run n8n under the matching architecture

# Native arm64
arch -arm64 n8n start

# Intel binary (if you installed the x86_64 formula)
arch -x86_64 n8n start

4.5 Optional: Create handy aliases

# Add to ~/.zshrc
alias n8n-arm='arch -arm64 n8n'
alias n8n-x86='arch -x86_64 n8n'

5. Verification & Troubleshooting Checklist

Step Command / Action Expected result
1 brew doctor “Your system is ready to brew.”
2 brew list –versions n8n Shows installed version (e.g., n8n 1.27.0)
3 which n8n Path inside Homebrew prefix (/opt/homebrew/bin/n8n or /usr/local/bin/n8n)
4 n8n version Prints the same version as step 2
5 n8n start (no errors) Console shows n8n ready on http://127.0.0.1:5678
6 Open browser → http://127.0.0.1:5678 UI loads without authentication errors
7 tail -f ~/.n8n/logs/*.log No stack traces related to missing binaries

If any step fails, revisit the relevant section above (Homebrew, Security, Apple Silicon).

6. Frequently Asked Questions

Question Short Answer
Do I need Docker if Homebrew fails? No. Homebrew is the recommended macOS method; Docker is covered in the *Docker installation error* child page.
Can I run n8n as a macOS service? Yes. After a successful install, create a launch daemon (~/Library/LaunchAgents/com.n8n.plist). See the pillar’s “Running n8n as a service” section for the exact plist.
Why does brew upgrade sometimes break n8n? Upgrading Node may invalidate native modules. Run npm rebuild inside $N8N_DATA_FOLDER or reinstall n8n (brew reinstall n8n).
Is it safe to disable Gatekeeper? Not recommended. Use xattr -d on the specific binary instead (see Section 3.1).

Conclusion

By ensuring Homebrew’s directory ownership, installing Rosetta 2 when needed, and explicitly selecting the correct architecture, you eliminate the most common macOS installation blockers for n8n. Adjusting Gatekeeper’s quarantine flag and redirecting the data folder sidesteps macOS security roadblocks without compromising system integrity. Follow the verification checklist to confirm a healthy, production‑ready n8n instance—ready to orchestrate your workflows on both Intel and Apple Silicon Macs.

Leave a Comment

Your email address will not be published. Required fields are marked *