Error koneksi n8n ke WordPress adalah **hal paling umum** bikin pemula stuck — padahal 90% solusinya sederhana & berulang. Artikel ini adalah **cheat sheet troubleshooting lengkap** untuk error: 401 Unauthorized, 403 Forbidden, 404 Not Found, 500 Internal Server Error, CORS, Rate Limit, Timeout, JSON Parse Error — dengan diagnosis step-by-step, solusi copy-paste, dan pencegahan.
Simpan artikel ini sebagai bookmark. Saat error, Ctrl+F kode error → ikuti solusi → solved.
Quick Diagnosis Flowchart
401 → Authentication (App Password, User, Credential) → Lihat Solusi 401
403 → Permission (Role, Capability, Plugin Block, WAF) → Lihat Solusi 403
404 → Endpoint (URL salah, REST API disabled, Permalink) → Lihat Solusi 404
500 → Server (PHP limit, Plugin conflict, Corrupt DB) → Lihat Solusi 500
CORS → Cross-Origin (Header, Cloudflare, Proxy) → Lihat Solusi CORS
429 → Rate Limit (WP, Server, Cloudflare) → Lihat Solusi 429
Timeout → Connection (DNS, Firewall, VPN, Large payload) → Lihat Solusi Timeout
JSON Parse → Response (HTML error page, Plugin output, Encoding) → Lihat Solusi JSON Parse
🔴 Error 401 Unauthorized — “Authentication Failed”
Gejala: n8n HTTP Request return 401, body: {"code":"rest_cannot_access","message":"Sorry, you are not allowed to do that.","data":{"status":401}}
Penyebab & Solusi (Urutkan dari Paling Umum)
| No | Penyebab | Diagnosis | Solusi |
|---|---|---|---|
| 1 | Application Password salah format | Password punya spasi? xxxx xxxx xxxx xxxx → base64 harus include spasi |
Buat App Password baru di WP Admin → Users → Profile → Application Passwords. Copy paste langsung (include spasi). Test: echo -n 'user:pass dengan spasi' | base64 |
| 2 | Credential n8n salah type | Pakai “Header Auth” tapi value bukan Basic base64 |
Header Auth → Header Name: Authorization → Header Value: Basic {{base64_encoded}}. JANGAN pakai “Basic Auth” credential type (deprecated). |
| 3 | User tidak punya capability publish_posts |
User role: Subscriber / Contributor / Custom role tanpa publish_posts | Ganti user ke Administrator / Editor. Atau tambah capability via plugin “User Role Editor” / functions.php: $role->add_cap('publish_posts'); |
| 4 | Application Password dicopy tanpa spasi | Copy dari UI → paste ke n8n → spasi hilang (jadi xxxxxxxxxxxxxxxx) |
Pastikan credential value include spasi. Test curl: curl -H "Authorization: Basic $(echo -n 'user:pass with spaces' | base64)" https://domain.com/wp-json/wp/v2/users/me |
| 5 | Two-Factor Authentication (2FA) aktif | Plugin 2FA (Wordfence, Google Authenticator) block REST API | Buat user terpisah untuk n8n (tanpa 2FA) ATAU whitelist IP VPS di plugin 2FA ATAU pakai Application Password (bypass 2FA di WP core). |
| 6 | Plugin Security Block (Wordfence, Sucuri, iThemes) | Log plugin: “Blocked REST API request from IP…” | Whitelist IP VPS n8n di plugin security. Atau disable “REST API protection” untuk user n8n. |
| 7 | Cloudflare/WAF Block | Cloudflare Firewall Rules / Bot Fight Mode challenge | Cloudflare → Security → WAF → Create Rule: (http.request.uri.path contains "/wp-json/") and (ip.src eq VPS_IP) → Action: Allow. |
| 8 | HTTPS Redirect Loop / Mixed Content | Site URL HTTPS tapi n8n request HTTP (atau sebaliknya) | Pastikan n8n request ke https://domain.com/wp-json/.... Set WP_HOME & WP_SITEURL di wp-config.php ke HTTPS. |
Test Cepat 401 (Copy-Paste ke Terminal VPS)
# Ganti user, app_pass, domain
USER="agus"
APP_PASS="m8Ef kxLc ljlX G7Gl GYFj WoUv"
DOMAIN="aguswibisono.com"
B64=$(echo -n "$USER:$APP_PASS" | base64)
curl -s -H "Authorization: Basic $B64" "https://$DOMAIN/wp-json/wp/v2/users/me" | jq .
Return 200 + user object = OK. Return 401 = cek table di atas.
🟠 Error 403 Forbidden — “Permission Denied”
Gejala: 403, body: {"code":"rest_forbidden","message":"Sorry, you are not allowed to do that.","data":{"status":403}}
| No | Penyebab | Diagnosis | Solusi |
|---|---|---|---|
| 1 | User role tidak punya capability | Role: Author/Contributor → tidak bisa publish_posts (hanya edit own drafts) | Ganti role ke Editor/Administrator. Atau custom capability via User Role Editor. |
| 2 | REST API disabled via plugin/code | add_filter('rest_enabled', '__return_false'); di functions.php / plugin |
Hapus filter disable. Atau enable REST API via plugin “WP REST API Controller”. |
| 3 | Plugin “Disable REST API” / “Disable WP REST API” | Plugin aktif & block semua /wp-json/ | Disable plugin. Atau configure allowlist untuk user n8n / IP VPS. |
| 4 | Plugin “Password Protected” / “Maintenance Mode” | Site dalam maintenance / password protected | Disable mode maintenance. Atau bypass via IP whitelist. |
| 5 | Cloudflare Bot Fight Mode / Turnstile | Challenge page return 403 HTML (bukan JSON) | Cloudflare → Security → Bot Fight Mode: OFF untuk API. Atau WAF Rule allow IP VPS. |
| 6 | ModSecurity / WAF Server Block | Shared hosting / VPS dengan ModSecurity rule trigger | Contact hosting support whitelist IP VPS & URI /wp-json/. Atau disable rule spesifik (id: 949110 dll). |
| 7 | Endpoint butuh capability spesifik | POST /posts butuh publish_posts, /media butuh upload_files |
Pastikan user punya capability sesuai endpoint. Editor: publish_posts + upload_files. Administrator: semua. |
🔵 Error 404 Not Found — “Endpoint Not Found”
Gejala: 404, body: {"code":"rest_no_route","message":"No route was found matching the URL and request method","data":{"status":404}}
| No | Penyebab | Diagnosis | Solusi |
|---|---|---|---|
| 1 | Permalink bukan “Post Name” | Settings → Permalinks → “Plain” atau custom tanpa rewrite | Set Permalinks ke Post Name (/%postname%/) → Save Changes. Ini regenerate rewrite rules. |
| 2 | URL endpoint salah | Typo: /wp-json/wp/v2/post (singular) vs /posts (plural) |
Endpoint standar: /wp-json/wp/v2/posts, /wp-json/wp/v2/media, /wp-json/wp/v2/categories, /wp-json/wp/v2/tags, /wp-json/wp/v2/users/me |
| 3 | WP instal di subfolder | Site di https://domain.com/blog/ tapi request ke /wp-json/ |
Request ke https://domain.com/blog/wp-json/wp/v2/posts. Atau setup subdomain blog.domain.com. |
| 4 | Nginx/Apache rewrite rules hilang | Migrasi server / update config → rewrite rule tidak include | Nginx: location / { try_files $uri $uri/ /index.php?$args; }. Apache: .htaccess WP standard. Reload web server. |
| 5 | REST API prefix berubah | Plugin/custom code: rest_url_prefix filter → jadi /api/ |
Cek https://domain.com/wp-json/ → namespace wp/v2 harus ada. Jika beda, adjust n8n URL. |
Test Cepat 404
curl -s "https://domain.com/wp-json/wp/v2/posts" | head -c 200
# Harus return JSON array (bisa kosong [])
# Jika return HTML 404 page → permalink/rewrite issue
🟣 Error 500 Internal Server Error — “Server Error”
Gejala: 500, body: {"code":"internal_server_error","message":"The server encountered an internal error..."} atau HTML error page.
| No | Penyebab | Diagnosis | Solusi |
|---|---|---|---|
| 1 | PHP Memory Limit habis | WP debug log: “Allowed memory size of 134217728 bytes exhausted” | wp-config.php: define('WP_MEMORY_LIMIT', '512M');. Atau php.ini: memory_limit = 512M. Restart PHP-FPM. |
| 2 | PHP Max Execution Time | Request lama > 30s (default) → timeout | wp-config.php: set_time_limit(300);. php.ini: max_execution_time = 300. Nginx: fastcgi_read_timeout 300;. |
| 3 | Plugin Conflict | Error setelah install/update plugin tertentu | Disable all plugins → test → enable satu-satu. Common culprit: page builder, security, SEO, cache plugin. |
| 4 | Corrupt Database / Table Crash | Error log: “Table ‘wp_posts’ is marked as crashed” | WP Admin → Tools → Database Repair. Atau phpMyAdmin: Repair table wp_posts, wp_postmeta. |
| 5 | PHP Version Incompatible | WP 6.5+ butuh PHP 8.1+, server pakai PHP 7.4 | Upgrade PHP ke 8.1/8.2/8.3. Test compatibility via plugin “PHP Compatibility Checker”. |
| 6 | Upload Size Limit (untuk media) | POST /media dengan file > upload_max_filesize | php.ini: upload_max_filesize = 64M, post_max_size = 64M. Nginx: client_max_body_size 64M;. |
| 7 | Yoast/RankMath Schema Conflict | Kirim _yoast_wpseo_schema JSON invalid |
Validate JSON schema sebelum kirim. Pastikan faq_schema valid JSON string (double escape di n8n). |
Debug 500: Enable WP Debug Log
# wp-config.php
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors', 0);
# Lalu cek log:
tail -f wp-content/debug.log
🟡 Error CORS — “Cross-Origin Request Blocked”
Gejala: Browser console: “CORS policy: No ‘Access-Control-Allow-Origin’ header”. Di n8n server-side biasanya tidak muncul CORS (server-to-server), tapi muncul jika n8n jalan di browser (n8n Cloud) atau test via browser.
| Penyebab | Solusi |
|---|---|
| WP tidak kirim header CORS | functions.php / mu-plugin: add_action('init', function() { header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS'); header('Access-Control-Allow-Headers: Authorization, Content-Type'); if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') exit(0); }); |
| Cloudflare block OPTIONS preflight | Cloudflare → Rules → Transform Rules → Modify Response Header: Add Access-Control-Allow-Origin: * untuk /wp-json/* |
| Nginx tidak pass header | Nginx config: add_header Access-Control-Allow-Origin * always; add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS" always; add_header Access-Control-Allow-Headers "Authorization, Content-Type" always; |
🟤 Error 429 Too Many Requests — “Rate Limited”
Gejala: 429, header: Retry-After: 60, body: {"code":"rate_limit_exceeded","message":"Too many requests..."}
| Source | Limit Typical | Solusi |
|---|---|---|
| WP REST API (plugin: “WP Rate Limit”, “Limit Login Attempts”) | 100 req/menit per IP/user | Whitelist IP VPS di plugin. Atau disable rate limit untuk REST API. |
| Server (Nginx limit_req_zone) | 10 req/s per IP | Nginx: limit_req_zone $binary_remote_addr zone=wp_api:10m rate=50r/s; increase rate. Atau exclude IP VPS. |
| Cloudflare Rate Limiting | Rule custom (contoh: 100 req/menit) | Cloudflare → Security → Rate Limiting Rules → Disable / Increase / Whitelist IP VPS. |
| Hosting Shared (CPU/Entry Process Limit) | Concurrent connection limit | Upgrade ke VPS / Cloud hosting. Atau batch request dengan delay. |
Best Practice di n8n: Anti Rate Limit
- Node Wait (3-5 detik) di loop section writing
- Node HTTP Request:
Continue On Fail: true,Retry On Fail: 3,Retry Delay: 10000(eksponensial) - Batch: max 3-5 artikel per run (Cron/Sheets limit)
- Jika 429: node IF check
{{$json.response.statusCode === 429}}→ Wait (parseRetry-Afterheader) → Retry (loop back)
⏱️ Error Timeout / ECONNREFUSED / ENOTFOUND
Gejala: n8n node error: ETIMEDOUT, ECONNREFUSED, ENOTFOUND, socket hang up
| Penyebab | Diagnosis | Solusi |
|---|---|---|
| DNS tidak resolve | nslookup domain.com gagal di VPS |
Cek /etc/resolv.conf (nameserver 8.8.8.8, 1.1.1.1). Restart systemd-resolved. Atau pakai IP langsung (tidak recommended). |
| Firewall VPS block outbound | ufw status / iptables -L block port 443 |
ufw allow out 443/tcp. Cloud provider firewall (AWS SG, DO Firewall) allow outbound 443. |
| WP Server block IP VPS | Test dari local: OK. Dari VPS: timeout | Contact hosting whitelist IP VPS. Atau cek fail2ban/CPHulk block. |
| Payload terlalu besar (media upload) | File > 10MB, request timeout 30s | Increase timeout: n8n node Options → Request Timeout: 120000 (2 menit). WP: increase PHP limits. |
| VPN/Proxy di VPS | VPS pakai VPN (Tailscale, WireGuard) → routing issue | Exclude WP domain dari VPN route. Atau disable VPN saat run workflow. |
| Cloudflare “Under Attack” Mode | Challenge page return 5s delay | Disable “Under Attack” mode. Atau WAF Rule allow IP VPS. |
📄 Error JSON Parse / Unexpected Token
Gejala: n8n node error: JSON.parse: unexpected character at line 1 column 1 atau Unexpected token '<'
| Penyebab | Diagnosis | Solusi |
|---|---|---|
| WP return HTML error page (bukan JSON) | Response body start with atau |
Cek actual response di n8n execution log (klik node → Output). Biasanya 403/500 HTML page. Fix root cause (403/500 di atas). |
| Plugin output buffer (whitespace di awal) | Response: \n\n{...} atau {...} |
functions.php: add_action('init', function() { ob_start(); }); — tapi hati-hati. Better: fix plugin yang output whitespace. |
| Encoding issue (BOM / UTF-16) | File wp-config.php / functions.php pakai UTF-16/BOM | Convert ke UTF-8 without BOM (VS Code / Notepad++ / sed). |
| n8n Response Format salah | Node HTTP Request → Response Format: "Auto" tapi return text | Set Response Format: JSON (force parse). Atau "File" lalu parse manual di Code node. |
Checklist Pencegahan (Setup Sekali, Aman Selamanya)
| No | Action | Frequency |
|---|---|---|
| 1 | Buat user dedikasi n8n (role Editor/Administrator) + Application Password | Once |
| 2 | Whitelist IP VPS di: Cloudflare WAF, Plugin Security (Wordfence), Hosting Firewall, ModSecurity | Once + saat ganti VPS |
| 3 | Set Permalinks "Post Name" + flush rewrite rules | Once |
| 4 | Increase PHP limits: memory_limit 512M, max_execution_time 300, upload_max_filesize 64M | Once |
| 5 | Disable plugin "Disable REST API", "Password Protected", "Maintenance Mode" | Once |
| 6 | Test curl dari VPS ke WP REST API (users/me, posts) sebelum bangun workflow | Once + saat deploy |
| 7 | Setup n8n node: Continue On Fail + Retry (3x, eksponensial) di semua node HTTP Request & AI | Per workflow |
| 8 | Add Error Trigger node → Telegram notif + Google Sheets log (Dead Letter Queue) | Per workflow |
| 9 | Monitor: UptimeRobot ping https://domain.com/wp-json/wp/v2/users/me (auth header) setiap 5 menit |
Ongoing |
| 10 | Backup credential n8n (export workflow + credential) ke GitHub private / Google Drive | Weekly |
Template Siap Pakai: Error Handling Sudah Built-In
Workflow Auto Content SEO di Kelas n8n Karyawan AI sudah include:
- ✅ Credential setup guide (video modul 2) — hindari 401/403
- ✅ Node HTTP Request:
Continue On Fail + Retry 3x eksponensial - ✅ Error Trigger node → Telegram notif detail + Google Sheets DLQ log
- ✅ Pre-flight check: Test WP connection sebelum run pipeline
- ✅ Rate limit handling: Wait node + retry logic di loop
- ✅ JSON parse safety: Response Format JSON + Code node validate
- ✅ Timeout config: Request Timeout 120s untuk media upload
- ✅ Debug helper: Node "Debug Response" (Set) output statusCode, headers, body preview
Setup: Import → Isi credential (sudah benar format) → Test connection → Active. Error handling otomatis jalan.
⚡ Error Handling Production-Ready Sudah Include di Template
401, 403, 404, 500, 429, Timeout, CORS, JSON Parse — semua covered. Import workflow, isi credential, jalan.
FAQ: Error n8n ke WordPress
Bagaimana cara lihat detail error di n8n?
Klik node yang error (merah) → Panel kanan "Execution Data" → tab "Error" → lihat statusCode, message, response.body. Atau klik "View" di error toast (kanan atas). Untuk debug response body: tambah node Set setelah node error (connect ke Error Trigger) → output error_body: {{$json.error.response.body}}.
Apakah harus pakai Application Password? Bisa pakai JWT / Basic Auth plugin?
Application Password adalah standar WP core (since 5.6) — paling stabil, tidak butuh plugin, support capability check, revoke per device. JWT (plugin "JWT Authentication") butuh plugin extra, kadang conflict, maintenance passive. Basic Auth plugin (deprecated) tidak support capability granular. Recommended: Application Password.
Error 403 tapi user sudah Administrator. Kenapa?
Kemungkinan: (1) Plugin security (Wordfence, Sucuri) block REST API untuk admin. (2) Cloudflare WAF block. (3) ModSecurity rule trigger. (4) Endpoint butuh capability spesifik (contoh: /media butuh upload_files). (5) Multisite: user bukan super admin. Cek log plugin/security/cloudflare → whitelist IP VPS.
Bagaimana handle error di loop (section writing) agar tidak stop seluruh artikel?
Node AI di loop: Continue On Fail: true, Retry On Fail: 2. Node IF setelah AI: check {{$json.error}} → True: set section HTML fallback (template error) + log error → Merge lanjut. False: normal. Di akhir Merge: hitung section success vs failed. Jika failed > 2 → Quality Gate reject artikel.
Apakah n8n Cloud (hosted) punya IP tetap untuk whitelist?
n8n Cloud IP dynamic (shared infrastructure). Untuk whitelist: (1) Pakai n8n Cloud webhook URL sebagai trigger (bukan outbound ke WP), lalu WP push via webhook (reverse). (2) Atau gunakan self-hosted VPS (IP statis) untuk production. (3) Atau disable rate limit/WAF untuk REST API (kurang aman). Recommended: self-hosted VPS untuk production.
Kesimpulan
Error koneksi n8n ke WordPress **90% disebabkan 3 hal**: (1) Application Password format salah (401), (2) User role/permission tidak cukup (403), (3) Permalink/rewrite rules (404). Sisanya: server limits, plugin conflict, Cloudflare/WAF.
Dengan checklist pencegahan di atas + error handling built-in di template kelas, Anda **hampir tidak akan stuck di error koneksi**. Fokus waktu Anda ke konten & strategi, bukan debugging koneksi.
🎯 Koneksi n8n-WP Stabil & Error-Resistant — Siap Pakai
Template include: credential guide, retry logic, error trigger, DLQ, pre-flight check, rate limit handling.