Fix nginx directive is not terminated by ";"
nginx 'directive is not terminated by ";"' means a "{" followed a directive with no semicolon. Fix the named line, and tell it apart from look-alike errors.
2026/11/02 22:14:55 [emerg] 12#12: directive "server_name" is not terminated by ";" in /etc/nginx/nginx.conf:6nginx: [emerg] directive "server_name" is not terminated by ";" in /etc/nginx/nginx.conf:6nginx: configuration file /etc/nginx/nginx.conf test failedThe directive in quotes (server_name) had no ;, and a { came after it. Add the ; at the end of the line where the named directive ends. The line number is the line holding the {, not the line missing the ;.
The same missing semicolon gives different messages depending on what comes next. This page separates the input that gives this message from the input that gives invalid number of arguments or unexpected end of file, using reproductions.
[1] Read the directive name and the line number from the error.
# nginx -tThe name after directive is the first word of the statement that lacks the ;, and the number at the end is the line of the { that ended it. If the error is in an included file, the path points to that file.
[2] Find the named directive in the config and look at the end of its line. Here the ; after root is missing, and the error points at line 6, where the { is.
root /srv/app location /api { return 204; }nginx: [emerg] directive "root" is not terminated by ";" in /etc/nginx/nginx.conf:6Add the ; to the root /srv/app line (line 5). Blank lines or comments in between change nothing: a statement runs until a ; or a { shows up.
[3] A { placed straight after a plain directive gives the same message. It appears for any directive that does not take a block (listen, server_name, root and so on).
listen 8081 {nginx: [emerg] directive "listen" is not terminated by ";" in /etc/nginx/nginx.conf:5Change it to listen 8081;. If the { was meant to open a block, the directive name is probably wrong; check whether you meant server or location.
[4] If the message is different, something else followed the missing ;. The same omission, with only the next token changed:
What follows the statement without ; | Error | Line |
|---|---|---|
{ (such as location /api {) | directive "root" is not terminated by ";" | the { line |
next directive ending in ;, directive takes exactly one argument (root) | invalid number of arguments in "root" directive | next line |
next directive ending in ;, directive takes several arguments (index) | no error | - |
} | unexpected "}" | the } line |
| end of file | unexpected end of file, expecting ";" or "}" | last line of the file |
[5] A directive that takes several arguments passes nginx -t. index takes a list of file names (index file ...;), so the error_page 404 /404.html; on the next line was swallowed into the index list.
index index.html error_page 404 /404.html;nginx: the configuration file /etc/nginx/nginx.conf syntax is oknginx: configuration file /etc/nginx/nginx.conf test is successfulA passing test does not mean error_page is in effect. Where several directives follow each other, read each line and confirm it ends in ;.
[6] A closing brace or the end of the file gives a different message.
location / { root /srv/app }nginx: [emerg] unexpected "}" in /etc/nginx/nginx.conf:7When the last statement of a file is the one missing the ;, parsing stops at the end of the file. The output below is from an nginx.conf that ends with worker_processes auto; an included file ending with proxy_set_header Host $host (conf.d/headers.conf) gave the same message with that file's path and line.
nginx: [emerg] unexpected end of file, expecting ";" or "}" in /etc/nginx/nginx.conf:3Brace problems have their own page: unexpected end of file, expecting "}".
[7] The opposite mistake reads differently. A directive that takes a block, such as location, with no { gives has no opening "{" instead.
nginx: [emerg] directive "location" has no opening "{" in /etc/nginx/nginx.conf:6[8] After fixing, test, and if it passes, apply it to the running nginx. nginx -t only checks the file; until you reload, the running nginx keeps working with its old configuration.
# nginx -tnginx: the configuration file /etc/nginx/nginx.conf syntax is oknginx: configuration file /etc/nginx/nginx.conf test is successfulOnce it passes, reload.
# nginx -s reloadThe nginx docs say a HUP signal to the master process makes nginx re-read the configuration, and nginx -s reload does that. The master first checks the syntax, then tries to apply the new configuration by opening log files and new listen sockets. The docs state that if this fails it rolls back the changes and keeps working with the old configuration. If nginx runs under systemd or another service manager, use that manager's reload command; its behavior was not checked here.
Analyze your Nginx log in the browser ↗ — nothing is uploaded.