How to Fix 404 and 502 Errors on CloudPanel

After deploying your website, particularly Python or Laravel-based website, you may encounter 502 error on your website. We will look at potential issues and how to resolve them

  1. uWSGI or Gunicorn not running.

One of these service provides a gateway for your website and it may not be running on your VPS. To check its status, run one of these commands:

For uWSGI:

systemctl status uwsgi

For gunicorn:

systemctl status gunicorn

If the service is not running, you can try restarting it.

systemctl restart uwsgi
systemctl restart gunicorn

2. Permissions

You may have uploaded the files as root, and the owner designated for the website in the VPS may not be root. This will cause 502 errors.

You can run the following command to check the owner and group allocated to the files:

ls -l

If your websites have owner root and/or group root, it will cause a permission issue to your website. You can use the following command to change:

chown -R owner:group /path/to/file

The owner and group should be the Site User of the current website. To check Site User, click the Setting tab on your website dashboard.

Also, the read/write permissions may be incorrect. Folders should have 755 while files should have 644. This allows them to be accessible, readable and writable where needed.

Use this commands to change them to the correct permissions

find . -type d -print0 | xargs -0 chmod 0755
find . -type f -print0 | xargs -0 chmod 0644

These are the two potential causes of 404 and 502 errors in websites migrated to CloudPanel. Ensure that the gunicorn or uWSGI socket is running, as well as the permissions are set correctly.

Was this article helpful?

Related Articles

Leave A Comment?