How to access Nginx error logs?

I had a particularly outdated ubuntu distribution (12.10) and was beginning the process to update sequentially to 16.04. Yesterday, I successfully updated from 12.10->13.10->14.04 using the Ubuntu old releases archive and this tutorial from Digital Ocean. I didn’t have to change the kernel, because our droplet was using grubloader v2.0.

Excited at the success of updating, I used do-release-upgrade to move from 14.04 to 16.04 and, while the distribution was updated successfully, I immediately ran into 502 errors (nginx /1.4.6) after updating. I am new to all of this, so I did the release upgrade from 14.04 to 16.04 in the exact same way as the 13.10->14.04 upgrade.

When I try to access the nginx error logs, I get a “Permission denied” reading. First question: How do I access the error logs? Second question (dependent on what the error logs might or might not show): has anyone run into this problem when updating from 14.04->16.04? Also, I restored my droplet back to 12.10 and updated back to 14.04 and I am now running into the same 502 errors, despite the 14.04 update working fine previously.

Here is the “Permission denied” code:

Welcome to Ubuntu 14.04.5 LTS (GNU/Linux 3.13.0-143-generic i686)

 * Documentation:
New release '16.04.4 LTS' available.
Run 'do-release-upgrade' to upgrade to it.

Last login: Wed Mar 21 12:34:48 2018 from
root@foss:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.5 LTS
Release:        14.04
Codename:       trusty
root@foss:~# /var/log/nginx/error.log
-bash: /var/log/nginx/error.log: Permission denied


The user of this folder is root, so you need to write something like this:

sudo tail -F /var/log/nginx/error.log

or this:

sudo cat /var/log/nginx/error.log

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

root@foss:~# /var/log/nginx/error.log

should be something more like

root@foss:~# cat /var/log/nginx/error.log

Hi there,

Just came across this question in 2020. Here are some suggestions for anyone who might need this:

Here is a link to an answer on how to troubleshoot common Nginx problems:

And here is also a quick video demo on how to do that as well:

Regards, Bobby

I have the same problem but still with no success, when I type cat /var/log/nginx/error.log I get cat: /var/log/nginx/error.log: Permission denied
I think the problem is the user of the folder, is not root, is www-data :

rails@mydroplet:/var/log$ ls -la


drwxr-x---  2 www-data  adm           4096 mai 21 06:39 nginx

what is this user? how can I solve, I can not access with sudo (root user)