Skip to content

nginx 502 error: nginx error.log failed (2: No such file or directory)

Updated 1 min read

Updated: 11 October 2026 · Applies to: AlmaLinux 9, Rocky Linux 9, Ubuntu 24.04 and Debian 12

Nginx fails to start with "could not open error log file: open() "/var/log/nginx/error.log" failed (2: No such file or directory)" when its log folder is missing or not writable.

Fix (root)

mkdir -p /var/log/nginx
chown -R nginx:nginx /var/log/nginx      # www-data:www-data on Ubuntu/Debian
nginx -t && systemctl restart nginx

Check which user Nginx runs as with the user line in /etc/nginx/nginx.conf.

Related services

Managed cPanel VPS

cPanel included; we handle updates, security and monitoring.

cPanel server management

hardening, migrations and 24/7 monitoring, with no long-term contract.

cPanel, Plesk and LiteSpeed licences

for VPS and dedicated servers, with installation help on demand.

Was this answer helpful?

Still stuck? Open a ticket