Troubleshooting LEMP Errors on Ubuntu

Troubleshooting LEMP Errors on Ubuntu

LEMP stack, consisting of Linux, Nginx, MySQL, and PHP, is a popular choice for hosting web applications. However, like any software stack, LEMP can encounter errors that may disrupt your website’s functionality. This article aims to guide you through some common LEMP errors on Ubuntu and provide troubleshooting steps to resolve them. If you are interested in purchasing an Ubuntu VPS server, you may want to explore the available packages on the Eldernode website.

How to Troubleshoot LEMP Errors on Ubuntu 

LEMP errors on Ubuntu refer to issues or problems that can occur within the LEMP stack, which consists of Linux, Nginx, MySQL/MariaDB, and PHP. You can use this software stack for hosting dynamic websites and web applications. Each component of the LEMP stack plays a crucial role, and errors can arise in any of them, leading to a malfunctioning or inaccessible website or application.




Recommended Article: Tutorial Limit SSH with UFW Firewall on CentOS

1. The “Welcome to Nginx!” page isn’t displaying:

– Check if Nginx is running by running the command ‘systemctl status nginx’. If it’s not active, try starting it with ‘systemctl start nginx’.

– Ensure that Nginx configuration files are error-free by running ‘nginx -t’. Any syntax errors need to be fixed.

– If you have multiple servers running on the same machine, make sure they’re not conflicting by checking configuration files in ‘/etc/nginx/sites-enabled/‘.

2. PHP pages result in a blank screen:

– Verify that PHP is installed by running ‘php -v’. If not, install it using ‘sudo apt-get install php-fpm’.

– Check the PHP-FPM service status with ‘systemctl status php-fpm’. If it’s not running, start it using ‘systemctl start php-fpm’.

– Ensure that Nginx is configured to correctly pass PHP requests to PHP-FPM. Check the Nginx configuration file at ‘/etc/nginx/sites-enabled/default’ and confirm that the ‘ocation ~ \.php$’ block points to the correct PHP-FPM socket.

3. The website displays “502 Bad Gateway” error:

– Restart the PHP-FPM service by running ‘systemctl restart php-fpm’. This might solve temporary issues with the PHP-FPM service.

– Check the PHP-FPM error log at ‘/var/log/php-fpm/error.log’ for specific error messages. Resolve any issues mentioned in the log file.

– If you recently made changes to Nginx configuration files, run ‘nginx -t’ to check for any syntax errors. Correct any errors found and restart Nginx with ‘systemctl restart nginx’.

4. The website shows “404 Not Found” for static files (CSS, JS, images):

– Confirm that the static files are located in the correct path and are accessible by running ‘ls /path/to/static/files’ and verifying that they exist.

– Ensure that the Nginx configuration file includes proper directives to serve static files. The ‘location /static/’ block in the Nginx config file should have the correct root path for serving static files.

– Check the file permissions of the static files and make sure they’re readable by the Nginx user (‘www-data’).

5. The server returns a “Connection refused” error:

– Check if the Nginx service is listening on port 80 by running ‘netstat -tuln | grep 80’. If it doesn’t show any output, Nginx might not be listening on the default port. Verify the `listen` directive in ‘/etc/nginx/sites-enabled/default’.

– Verify that there are no conflicting services running on port 80, such as Apache. Stop any conflicting services using ‘systemctl stop apache2’ (for Apache).

– If you recently modified the firewall settings, ensure that port 80 is open by running ‘ufw status’. If it’s not, open it with ‘ufw allow 80’ and reload the firewall rules with ‘ufw reload’.

Remember to always backup configuration files before making any changes and refer to official documentation for the specific software versions you’re using.

Recommended Article: Tutorial How to install and configure PHP on Ubuntu 20.04


Troubleshooting LEMP errors on Ubuntu requires a systematic approach to identifying and resolving issues. By following the steps outlined in this article, you can effectively tackle common errors encountered in the LEMP stack, ensuring the smooth operation of your web applications.

How useful was this post?

Click on a star to rate it!

Average rating 1 / 5. Vote count: 1

No votes so far! Be the first to rate this post.

View More Posts
Tom Veitch
Eldernode Writer
We Are Waiting for your valuable comments and you can be sure that it will be answered in the shortest possible time.

Leave a Reply

Your email address will not be published. Required fields are marked *

We are by your side every step of the way

Think about developing your online business; We will protect it compassionately

We are by your side every step of the way


7 days a week, 24 hours a day