website down but server is fine(nginx)

Posted October 7, 2021 109 views
NginxWordPressDigitalOcean Droplets

It has been going on for the last week or so, this issue and I cannot seems to pin point the exact issue. I have a monitor set up which emails me when the site is down in day it can be done for up to 3 times and if I do not reboot the droplet it will take around 2-3 hours before the site is back up and running again.

Droplet information

2 GB Memory / 60 GB Disk / LON1
Ubuntu 20.04.3 LTS

I have 2 ecommerce wordpress sites running on this droplet.

Sudo ufw status

Status: active

To                         Action      From
--                         ------      ----
22                         ALLOW       Anywhere
80                         ALLOW       Anywhere
443                        ALLOW       Anywhere
21/tcp                     ALLOW       Anywhere
Nginx Full                 ALLOW       Anywhere
22 (v6)                    ALLOW       Anywhere (v6)
80 (v6)                    ALLOW       Anywhere (v6)
443 (v6)                   ALLOW       Anywhere (v6)
21/tcp (v6)                ALLOW       Anywhere (v6)
Nginx Full (v6)            ALLOW       Anywhere (v6)
df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            984M     0  984M   0% /dev
tmpfs           200M  688K  199M   1% /run
/dev/vda1        58G   16G   43G  27% /
tmpfs           997M     0  997M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           997M     0  997M   0% /sys/fs/cgroup
/dev/vda15      105M  8.9M   96M   9% /boot/efi
tmpfs           200M     0  200M   0% /run/user/0

I do not know what else to check. Please help.

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
2 answers

Hi @uakpan,

When you receive the message that your website is down can you check your Nginx. Try restarting it, does it help?

Additionally, have you checked the load on the server is it more than the usual? What I believe is going on is you reaching the limit of MaxRequests on your Nginx instance and restarting it should resolve the issue. Can you please confirm this the next time your website goes down?

  • Hi, I tried sudo systemctl restart nginx seems to be okay but it was extremely slow and then my colleague couldn’t access the site so I had to go a reboot again. Please can you talk me through step by step what to do please or if you have a link to an resources. Thank you

    • Hi @uakpan,

      It seems like you are getting some high load on your Droplet. Next time you have to restart Nginx, check your load and processes using htop.

      You’ll need to troubleshoot your Droplet to see where this is coming from.

      In another answer, I’ll post the typical ways to optimize your Droplet and Website.

Let’s start with Server Optimization.

When looking at Server/Droplet Optimization, there are a few necessary services/packages that are universal.

  • The first one would be Server-side caching. Server cache is an umbrella term covering a number of different types of caching. This includes Content Delivery Network (CDN) caching, object caching, and opcode caching. Depending on what you want to achieve you might need one or the other. Usually, though, you can have all 3 types of caching as it shouldn’t interfere with your Website/App. I won’t go into more details about what each caching does as this post will become 3 pages long. There are multiple documents providing services/packages for each of the server-type caching.

  • Next would be using PHP-FPM (if your Website is using PHP of course). PHP-FPM is an efficient method on how to minimize the memory consumption and rise the performance for the Websites with heavy traffic. It is significantly faster than traditional CGI-based methods in multi-user PHP environments.

  • Another solution would be Database Caching. A database cache supplements your primary database by removing unnecessary pressure on it, typically in the form of frequently accessed read data. The cache itself can live in a number of areas including your database, application or as a standalone layer. Usually, for this kind of caching is being used Redis.

Those were the basic optimizations on a server level, let’s start with your Website/App

If you are using a CMS like WordPress, Magento, Joomla, Opencart or anything of the same matter, there will be plugins/addons. These addons can be very powerful if used correctly. The most helpful plugins are:

  • Caching Plugins
  • Image Optimization Plugins
  • Plugins that reduce redirections/requests
  • Plugins that reduce the size of JS and CSS files.
  • More often than not, there are a lot of JS and CSS files that are not being used, removing those should work as well

If you are not using a CMS, you’ll need to try and do what these plugins are doing manually.

Usually, Websites/Apps are slow because of a couple of reasons which range from too many requests or big images to a bunch of unnecessarily big JS or CSS files. Optimizing these whether you are using a Plugin or doing it manually is enough.

I hope this was helpful.

  • Additionally, you can check MySQL:

    You can check the MySQL configuration and see if there is anything that can be optimized for MySQL to work better

    What you can also do is to use the MySQLTuner script.

    The MySQLTuner is a script written in Perl and allows you to quickly test your MySQL configuration and it gives you suggestions for adjustments to increase performance and stability.

    According to the official GitHub page, it supports 300 indicators for MySQL/MariaDB/Percona Server in this last version.

    To run the script you could do the following:

    • SSH to your Droplet
    • Download the script:
    wget -O
    • Then execute it:

    The script would run multiple checks against your MySQL instance, all checks done by MySQLTuner are documented here.

    Also as stated in the official documentation, it is still extremely important for you to fully understand each change you make to a MySQL database server. If you don’t understand portions of the script’s output, or if you don’t understand the recommendations, you should consult a knowledgeable DBA or system administrator that you trust.

    As a good practice make sure to always test your changes on staging environments before implementing them on your production database.

    On the same note, if you want to have worry-free MySQL hosting and focus on your application, I would recommend trying out the DigitalOcean Managed Databases:

    This was mini tutorial was posted from bobbyiliev in this question in our community: