Troubleshoot NGINX Config That Fails nginx -t Prompt
Diagnose and fix an NGINX configuration that fails `nginx -t` by reading the exact error/line, explaining the underlying cause, and returning a corrected, test-passing config with the change isolated.
- Target user
- DevOps engineers and sysadmins editing NGINX configs
- Difficulty
- Beginner
- Tools
- Claude, ChatGPT
The prompt
You are a senior NGINX engineer who debugs configuration failures. My config fails `nginx -t` (or reloads cleanly but behaves wrong) and I need it fixed without breaking the rest. I will provide: - The full `nginx -t` (or `nginx -T`) output, including the exact error message and `in /path:line` - The offending file/block (paste enough surrounding context, not just the flagged line) - The NGINX version and which modules are compiled in (relevant for "unknown directive") - What the config is supposed to do Your job: 1. **Read the error literally** — translate the `nginx -t` message (e.g. "unexpected }", "directive is not allowed here", "unknown directive", "duplicate location", "host not found in upstream") into its precise meaning. 2. **Locate the real cause** — the flagged line is often a symptom of an unclosed brace, a directive in the wrong context, a missing `;`, or a module that isn't loaded; find the actual source. 3. **Explain context rules** — if a directive is "not allowed here," state which context (main/http/server/location) it belongs in and why. 4. **Fix minimally** — return only the corrected block(s) with the change clearly marked, preserving formatting and unrelated directives. 5. **Catch related issues** — scan the surrounding config for the same class of mistake that will fail on the next reload. 6. **Verify safely** — give the `nginx -t` re-check, then `nginx -s reload` (not restart) so live connections drain. Output as: (a) plain-English error explanation, (b) root cause, (c) corrected block with the diff marked, (d) test + reload steps.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
Fix NGINX Location Block Precedence Prompt
Untangle why the wrong NGINX location block is matching a request by tracing prefix vs regex vs exact-match precedence, then reorder/rewrite the blocks so each URL hits the intended handler.
-
Configure NGINX TLS, HSTS & OCSP Stapling Prompt
Build a modern, A-grade NGINX TLS configuration with correct protocol/cipher selection, OCSP stapling, session settings, and a safe HSTS rollout, then verify it against a real handshake.
-
Debug NGINX 502/504 Upstream Errors Prompt
Diagnose why NGINX returns 502 Bad Gateway or 504 Gateway Timeout from an upstream by correlating the error log, the proxy block, and upstream health into a ranked root-cause list with fixes.
-
NGINX 502/504 Bad Gateway Triage Prompt
Turn a wall of error.log lines plus your upstream config into a ranked root-cause list and a concrete fix for 502/504 errors — without guessing or restarting blindly.
More NGINX prompts & error guides
Browse every NGINX prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.