Question

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:  https://help.ubuntu.com/
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 c-73-205-79-49.hsd1.fl.comcast.net
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
root@foss:~#

Show comments

Submit an answer


This textbox defaults to using Markdown to format your answer.

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

Sign In or Sign Up to Answer

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

Bobby Iliev
Site Moderator
Site Moderator badge
November 7, 2020

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:

https://www.digitalocean.com/community/questions/how-to-troubleshoot-common-nginx-issues-on-linux-server

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

shows

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)

thanks

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.