How to access Nginx error logs?

Posted March 21, 2018 71k views

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

1 comment
  • 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

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.

Submit an Answer
3 answers

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

should be something more like

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

  • This worked! Thank you. I was able to find out that my error logs show an inability to connect to a file called php5-fpm-soc

    2018/03/22 10:01:08 [crit] 774#0: *58351 connect() to unix:/var/run/php5-fpm.soc                                                                                               k failed (13: Permission denied) while connecting to upstream, client: 46.229.16                                                                                               8.67, server: localhost, request: "GET /tag/love-me-some-cats/ HTTP/1.1", upstre                                                                                               am: "fastcgi://unix:/var/run/php5-fpm.sock:", host: ""

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)


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: