nginx/nginx · error
%*s in %s:%ui
Error message
%*s in %s:%ui
What it means
Location suffix that ngx_conf_log_error() appends to every configuration error raised while a config file is open: it prints the already-formatted error text followed by ' in <config-file>:<line>'. Before the config file is open the bare text is logged, and for errors that come from command-line arguments ('nginx -g ...') it prints 'in command line' instead. Seeing this message means a directive-level error was detected and nginx is pointing at the exact file and line to fix.
Source
Thrown at src/core/ngx_conf_file.c:1019
p = ngx_vslprintf(errstr, last, fmt, args);
va_end(args);
if (err) {
p = ngx_log_errno(p, last, err);
}
if (cf->conf_file == NULL) {
ngx_log_error(level, cf->log, 0, "%*s", p - errstr, errstr);
return;
}
if (cf->conf_file->file.fd == NGX_INVALID_FILE) {
ngx_log_error(level, cf->log, 0, "%*s in command line",
p - errstr, errstr);
return;
}
ngx_log_error(level, cf->log, 0, "%*s in %s:%ui",
p - errstr, errstr,
cf->conf_file->file.name.data, cf->conf_file->line);
}
char *
ngx_conf_set_flag_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
char *p = conf;
ngx_str_t *value;
ngx_flag_t *fp;
ngx_conf_post_t *post;
fp = (ngx_flag_t *) (p + cmd->offset);
if (*fp != NGX_CONF_UNSET) {
return "is duplicate";View on GitHub (pinned to 3f6f7824d4)
Solutions
- Open the exact file:line named at the end of the message and fix the problem named at the start of the message
- If the named line looks valid, inspect the preceding lines for a missing semicolon or unclosed quote - the parser often fails on the line after the actual mistake
- Run 'nginx -t' after fixing to confirm the whole include tree parses before reloading
- For messages ending in 'in command line', fix the string passed to 'nginx -g' or the systemd unit's -g option, not a file
Example fix
# before: nginx: [emerg] unknown directive "worker_process" in /etc/nginx/nginx.conf:3 worker_process 2; # after worker_processes 2;
Defensive patterns
Strategy: validation
Validate before calling
nginx -t # parse the full config tree (all includes) before any reload nginx -T 2>/dev/null | grep -n 'worker_process ' # locate the offending line in the effective config
Prevention
- Run 'nginx -t' in CI and in deploy scripts before every 'nginx -s reload'
- Split large configs into includes so file:line attribution stays precise
- Treat messages ending in 'in command line' as coming from 'nginx -g' options, not from files
When it happens
Trigger: Any directive handler calling ngx_conf_log_error() during parsing of nginx.conf or an included file: unknown directive, wrong argument count, invalid value, duplicate directive, failed include, module init failure. Appears at startup, at reload, and in 'nginx -t' output.
Common situations: Typos in directive names or values; a missing semicolon that makes the parser fail on the line after the real mistake; editing included files (conf.d/*.conf) and misreading which file:line the error names; errors from systemd 'ExecStart=... -g' options reported as 'in command line'.
Related errors
- NGX_LOG_WARN
- NGX_LOG_EMERG
- NGX_LOG_WARN
- [alert] could not open error log file: \"%s\" failed
- NGX_LOG_EMERG
AI-assisted analysis of nginx/nginx@3f6f7824d4 (2026-08-22).
Data as JSON: /api/errors/f55b1ad442c91672.
Report an issue: GitHub.