×


Vestacp 502 bad gateway error

Are you trying to fix Vestacp 502 bad gateway?

This guide is for you.


VestaCP is an open-source web control panel that is considered to be a great alternative to cPanel.

Vestacp 502 bad gateway issue occurs mainly due to lack of disk space or vesta session problems.

This error can also occur when a web server takes more time to complete and a caching tool reaches its timeout values that time. 


Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to resolve VestaCP related errors.

In this context, we shall look into how to tackle this gateway error.


How to fix Vestacp 502 bad gateway error ?

Some of the common causes for Vestacp 502 bad gateway includes disk space issue, vesta session problem or even PHP-fpm service issues. 

Here we will look into methods to resolve this error.


1. Lack of Disk Space

One of the most common reasons for this error is the disk space issue.

When disk space reaches the limit the Vestacp returns 502 gateway error.

To fix this we will check the disk space usage and availability using the below command:

df -h

If we notice the storage to be full, we can delete some unnecessary files and folders to increase the available space.

This is one way to fix this gateway error.


2. Vesta Session problem

We will delete the current vesta session folder to fix this.

The steps to follow are:

i. SSH to the server.

ii. Then delete /usr/local/vesta/data/sessions folder using the following command:

rm -R /usr/local/vesta/data/sessions

iii. Next we will create a new session folder using the following command:

mkdir  /usr/local/vesta/data/sessions

iv. After that, we will set the permission to 775 for the folder using the following command:

chmod -R 775 /usr/local/vesta/data/sessions

v. And we will change the owner of the folder to admin: admin with the following command:

chown -R admin: admin /usr/ local/vesta/data/sessions

vi. After that, we check the file  /usr/local/vesta/php/etc/php-fpm.conf and make sure the file path.

php_admin_value [session.save_path] = /usr/local/vesta/data/sessions

vii. Now we will edit the file /usr/local/vesta/php/etc/php-fpm.conf  by adding the following lnes:

vi /usr/local/vesta/php/etc/php-fpm.conf​
php_admin_value [memory_limit] = 256M
php_admin_value [post_max_size] = 512M
php_admin_value [upload_max_filesize] = 512M
php_admin_value [max_execution_time] = 600
php_admin_value [max_input_time] = 600
php_admin_value [session.save_path] = /usr/local/vesta/data/sessions

viii. Finally, we will restart the vesta service:

vesta service restart

3. Restarting the PHP-fpm service.

At times, the PHP-fpm service causes this 502 gateway time out error. So we will try restarting the service using the following command:

service php-fpm restart


[Still, stuck with this VestaCP error?- We'll help you. ]


Conclusion

This article will guide you on common causes for #Vestacp #502 bad gateway #error and different methods to fix this error.

A 502 Bad Gateway indicates that the edge server (server acting as a proxy) was not able to get a valid or any response from the origin server (also called upstream server).

Server software timeouts: This error can also occur when a web server takes more time to complete and a caching tool reaches its timeout values that time. Slow queries can also cause this problem too.'

To fix Error 502 Gateway:

1. Refresh the page.

2. Start a new browser session or load the site on a different browser.

3. Restart your computer and networking equipment.

4. Clear your #cache and cookies.

5. Change your #DNS server.