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.

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

More NGINX prompts & error guides

Browse every NGINX prompt and troubleshooting guide in one place.

Free download · 368-page PDF

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.