GrepBoard/Manuals
605 manuals ·

nginx log location: find and read access.log, error.log

·Tested on nginx 1.30.6 (Docker nginx:stable) · distro paths per nginx docs · 2026-11·Test scope ↓·5 steps

Find the nginx log location, see why the Docker image needs docker logs, read one line of each log, and jump to the right fix for your symptom.

nginx keeps a request log (access.log) and a problem log (error.log). A 502 shows up as a number in access.log; the reason is in error.log. The output below comes from an nginx:stable container (nginx 1.30.6).

[1] Check the paths. The nginx docs give the default error.log as /var/log/nginx/error.log on RHEL-based systems, Debian and Ubuntu, and /usr/local/var/log/nginx/error.log on FreeBSD. The official Docker image sends logs to the container log instead. For a source build, the beginner's guide points to /usr/local/nginx/logs or /var/log/nginx. Do not guess; print the paths compiled into your binary.

console
$ nginx -V 2>&1 | tr " " "\n" | grep -E "log-path"--error-log-path=/var/log/nginx/error.log--http-log-path=/var/log/nginx/access.log

[2] Check that the configuration does not override them. The access_log and error_log lines from nginx -T are the real paths.

console
$ nginx -T 2>/dev/null | grep -nE 'log_format|access_log|error_log'6:error_log  /var/log/nginx/error.log notice;19:    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '23:    access_log  /var/log/nginx/access.log  main;142:    #access_log  /var/log/nginx/host.access.log  main;

Line 142 is commented out with # and has no effect. This is the configuration of the nginx:stable image; a distro package's nginx.conf may differ. [3] In a Docker container, use docker logs instead of reading files. The official image links both files to the standard streams.

console
$ ls -l /var/log/nginxtotal 0lrwxrwxrwx 1 root root 11 Nov  5 07:18 access.log -> /dev/stdoutlrwxrwxrwx 1 root root 11 Nov  5 07:18 error.log -> /dev/stderr

docker logs mixes both streams, so drop one to see the other (container name web assumed). The first command shows stdout, which is access.log; the second shows stderr, which is error.log. The Docker logging docs describe the same links.

console
$ docker logs web 2>/dev/null$ docker logs web 2>&1 >/dev/null

[4] Read one access.log line. These two lines come from one request for GET / and one for a missing file, GET /missing.html.

output
127.0.0.1 - - [08/Nov/2026:22:05:10 +0000] "GET / HTTP/1.1" 200 896 "-" "gb-test/1.0" "-"127.0.0.1 - - [08/Nov/2026:22:05:10 +0000] "GET /missing.html HTTP/1.1" 404 153 "-" "gb-test/1.0" "-"
FieldMeaning
127.0.0.1Client address. Behind a proxy, this is the proxy's address
- -A fixed placeholder, then the basic-auth user (- if none)
[08/Nov/2026:22:05:10 +0000]Time and time zone
"GET /missing.html HTTP/1.1"Method, path, protocol
404 153Status code, response body bytes
"-" "gb-test/1.0"Referer, User-Agent
"-"X-Forwarded-For header passed by a proxy

The predefined combined format has no trailing X-Forwarded-For field. This image adds it and names the result main (ngx_http_log_module). If your log_format differs, the fields shift, so check the line from [2] first.

[5] Read one error.log line. Both lines are from the same test: a startup notice, then the error left by the /missing.html request.

output
2026/11/08 22:05:08 [notice] 1#1: start worker processes2026/11/08 22:05:10 [error] 29#29: *2 open() "/usr/share/nginx/html/missing.html" failed (2: No such file or directory), client: 127.0.0.1, server: localhost, request: "GET /missing.html HTTP/1.1", host: "localhost"

Left to right: the time (no time zone shown), [error] is the severity, 29#29 is the process and thread ID, *2 is the connection number. The sentence after it is the cause, and client:, server:, request:, host: say which request it was. Match it to the 404 line in access.log by time and by the request: value.

The second value of error_log is the lowest severity that gets written. The documented default is error; this image uses notice, which is why the startup lines appeared. debug only works in an nginx built with --with-debug.

[6] Pick the next article by symptom.

What you seeRead
502Tell the cause from error.log
504, upstream timed outTell which timeout fired
413 on uploadclient_max_body_size
403, Permission deniedPermissions vs index
(24: Too many open files)Fix
Which paths return 5xxCount with awk
Slow requestsAdd response times
JSON logs · ?token= exposedescape=json · Redact the value

Analyze your Nginx log in the browser ↗ — nothing is uploaded.

#nginx#logs#access.log#error.log#docker