Skip to content
DevOps AI ToolKit
Newsletter
All prompts
AI for NGINX Difficulty: Beginner ClaudeChatGPT

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.

Related prompts

Newsletter

Free: the DevOps AI Incident-Triage Cheat Sheet

Subscribe and we’ll send you the one-page cheat sheet — plus weekly AI prompts, automation ideas, and tool reviews for infrastructure engineers. One email a week. No spam, unsubscribe anytime.

  • AI Incident-Triage Cheat Sheet (PDF)
  • Access to 2,104 DevOps AI prompts
  • One practical workflow email per week