Nginx: nginx: [emerg] unexpected end of file, expecting ";" or "}" in /etc/nginx/conf.d/site.conf:42
The config ends while a block or directive is still open — a missing } or ;.
nginx: [emerg] unexpected end of file, expecting ";" or "}"[emerg] unexpected end of file, expecting ";" or "}" in /etc/nginxnginx: [emerg] unexpected "}" in /etc/nginx/nginx.confnginx: configuration file /etc/nginx/nginx.conf test failed[emerg] unexpected end of parameter, expecting ";" Meaning
The line number points at the end of the file, but the mistake is earlier: an unclosed server {/location { or a directive lacking ;. Run nginx -t, then check brace balance (grep -c '{' file; grep -c '}' file) and view the file with an editor that highlights brackets.
Common causes
- Missing closing brace
} - Missing
;after a directive - Unbalanced braces after a copy-paste
- Included snippet missing its closing brace
- Stray character from an editor
⚡ Quick fix
sudo nginx -tto get file and line- Balance braces; add the missing
;or} - Use an editor with bracket matching; validate each included file
Detailed fix by platform
Linux
sudo nginx -t && sudo systemctl reload nginx; count braces:grep -o '{' site.conf | wc -l; grep -o '}' site.conf | wc -l
How to diagnose
- Line — File end?
- Braces — Balanced?
- Include — Which file?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- AH00526: Syntax error on line of apache config Apache: AH00526: Syntax error on line 12 of /etc/apache2/sites-enabled/site.conf: Invalid command 'Foo', perhaps misspelled or defined by a module not included in the server configuration
- could not build the server_names_hash, you should increase server_names_hash_bucket_size Nginx: nginx: [emerg] could not build the server_names_hash, you should increase server_names_hash_bucket_size: 64
- nginx: [emerg] open() failed (2: No such file or directory) Nginx: nginx: [emerg] open() "/etc/nginx/snippets/fastcgi-php.conf" failed (2: No such file or directory) in /etc/nginx/sites-enabled/app:20
Most viewed in Nginx / Apache
- upstream timed out Nginx: upstream timed out (110: Connection timed out) while reading response header from upstream
- AH00558 Apache: AH00558: apache2: Could not reliably determine the server's fully qualified domain name
- AH00072: make_sock: could not bind to address 0.0.0.0:80 Apache: (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80 / AH00015: Unable to open logs
Other ways to find it
Where this error sits
Origin: Edge & web server. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 5 Nov 2026