Nginx cannot write into access.log Nginx cannot write into access.log linux linux

Nginx cannot write into access.log


Depending on your configuration, nginx master process and worker processes likely run as different users.

To see users and groups for nginx processes:

ps -eo "%U %G %a" | grep nginxroot     root     nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.confwww-data www-data nginx: worker process

The worker process user needs write permission for the log file.

To see file permissions of access.log:

ls -l /var/log/nginx/access.log-rw-r----- 1 www-data www-data 0 Apr 29  2012 /var/log/nginx/access.log

In this case, access log is owned by the nginx worker process and has write access.

See also nginx http_log_module docs.

As a secondary issue, nginx logs may be rotated once they reach a certain size by the logrotate cronjob. When the new log file is created, it should be created with owner, group and permissions to allow the nginx worker process to write to it.

These log rotation settings for nginx are defined in /etc/logrotate.d/nginx

See also log rotation guide for ubuntu.


I had a similar problem where the access logs file was not getting written to, but the error log file was working fine. The permissions were also fine for me. I got it to fix itself by forcing the nginx process to reload log files using

kill -USR1 `cat /var/run/nginx.pid`

where /var/run/nginx.pid is the path to your nginx PID file


You must bind the user and group nginx to your log-files.

chown nginx:nginx access.logchown nginx:nginx error.log

Can you post your complete nginx.conf? With pastebin for example?

EDIT: in every section you must define the keyword like "combined"!