Arama Yap Mesaj Submit
Request a Callback
+90
X
X

Select Your Currency

Turkish Lira $ US Dollar Euro
X
X

Select Your Currency

Turkish Lira $ US Dollar Euro

Contact Us

Location Halkali merkez neighborhood fatih st ozgur apt no 46 , Kucukcekmece , Istanbul , 34303 , TR
Plesk Obsidian Technical Guide

How to Fix Plesk 502 Bad Gateway and 504 Gateway Timeout Errors?

502 and 504 errors on Plesk server mean that the request has reached Nginx or Apache, but PHP-FPM, FastCGI, or the backend service has not responded in time with a healthy response.

502 Bad Gateway504 Gateway TimeoutPHP-FPMNginx upstreamPlesk repair web
root@server:~SSH
502 Bad Gateway
connect() to unix:/var/www/vhosts/system/example.com/php-fpm.sock failed
(11: Resource temporarily unavailable) while connecting to upstream
upstream timed out (110: Connection timed out)
Proxy layerNginx and Apache connection
PHP layerPHP-FPM socket and pool status
Source limitmax_children, RAM and heavy request
right approachSplit scope, match log, verify
01
Technical description

What does Plesk 502 and 504 errors mean?

502 Bad Gateway indicates that the proxy layer couldn't get a valid response from the backend; 504 Gateway Timeout indicates that the backend didn't respond within the specified time. Both errors seem similar, but the solution should be based on the log messages of socket, timeout, and process.

If only one domain is affected, the PHP handler selection of the related domain, the PHP-FPM pool, the application code, and the records in the /var/www/vhosts/system/domain/logs directory are examined.

If all sites are affected, Nginx, Apache, installed Plesk PHP-FPM services, global RAM, file identifiers, and the last update operations are checked.

php-fpm.sock failed: No such file or directory, which may indicate that the expected socket file for the domain has not been created or the domain is bound to a removed PHP handler.

Even if the service appears to be working, when the resource limit or heavy traffic causes the pool to be full, new requests cannot be forwarded to the back-end. Therefore, restarting alone is not a permanent solution.

Increasing the timeout value is useful for tasks that are truly supposed to take a long time. It should not be used solely to hide the wait time for a slow query, bot attack, or a locked PHP process for a normal page.

02
Log messages and their meanings

Plesk 502, 503, 504, and PHP-FPM error messages

Search for the phrase you see in the email, browser, or SSH log. Each card includes meaning, probable cause, and safe initial action.

8 registration
01kritik

502 Bad Gateway

Meaning: Nginx or Apache failed to retrieve a valid HTTP response from the backend.

Possible cause: PHP-FPM is closed, socket lost, connection refused, or the process terminated abruptly.

Check the domain proxy_error_log and PHP-FPM service status over the same time period.
02kritik

504 Gateway Timeout

Meaning: Proxy, response could not be obtained within the specified time from the backend.

Possible cause: Long-running PHP process, slow SQL query, external API wait, or low proxy timeout.

Determine the request time from the log; do not increase the timeout without fixing the code slowness.
03kritik

connect() to php-fpm.sock failed (2: No such file or directory)

Meaning: The PHP-FPM socket path cannot be found in the file system.

Possible cause: PHP handler removed, missing pool file or web configuration is outdated.

Verify the PHP handler of the domain and recreate the web configuration only for the relevant domain.
04kritik

(111) Connection refused while connecting to upstream

Meaning: The socket or port is available, but the backend connection has not been accepted.

Possible cause: PHP-FPM service may be stopped, pool crashed or incorrect endpoint used.

Check the related Plesk PHP-FPM service and pool log.
05warning

(11) Resource temporarily unavailable

Meaning: New connection or process cannot be temporarily separated.

Possible cause: PHP-FPM pool full, process limit high under heavy load or DDoS traffic

Compare pm.max_children with active processes and the IP address with the highest request count.
06warning

server reached pm.max_children setting

Meaning: The concurrent child process limit has been reached in the PHP-FPM pool.

Possible cause: High traffic, slow request, or low pool capacity.

Do not increase the limit without measuring the average RAM consumption of each PHP process.
07warning

upstream timed out while reading response header

Meaning: Back-end connection established but response header not received in time.

Possible cause: The application, database, or external service is experiencing a delay.

Examine slow query, PHP slowlog, and application log for the same URL.
08kritik

503 Service Unavailable after PHP handler removal

Meaning: The domain is bound to a non-existent or broken PHP handler.

Possible cause: PHP version has been removed, but the domain configuration remains the same

Select the existing handler from Plesk PHP settings and repair the domain configuration.

No records matching this expression were found.

03
Secure first review

SSH diagnostic commands and what output to look for?

Commands are for root access. Collect only status and logs first; Do not change the permanent setting without seeing the reason.

HTTP and scope test
curl -skI https://example.com/
curl -skI https://example.com/test.html

It distinguishes whether the problem is a proxy or an application by comparing static and PHP responses.

Domain web logs
tail -n 150 /var/www/vhosts/system/example.com/logs/proxy_error_log
tail -n 150 /var/www/vhosts/system/example.com/logs/error_log

Displays Nginx, Apache, and PHP backend messages on a domain basis.

Web servisleri
systemctl status nginx --no-pager
systemctl status apache2 --no-pager 2>/dev/null || systemctl status httpd --no-pager

Checks the status of Nginx and Apache services based on distribution.

Plesk PHP-FPM servisleri
systemctl list-units --type=service 'plesk-php*-fpm.service' --no-pager
ps -eo pid,user,%cpu,%mem,etime,cmd --sort=-%cpu | grep 'php-fpm' | head -n 30

Lists the installed PHP-FPM services and intensive processes.

Domain configuration check
plesk repair web example.com

It controls the web configuration of the related domain and suggests interactive repair.

Source and OOM control
free -h
journalctl -k --since '1 hour ago' | grep -Ei 'oom|out of memory|killed process'

Shows global memory pressure or kernel OOM event.

IPs sending heavy requests
tail -n 10000 /var/www/vhosts/system/example.com/logs/proxy_access_log | awk '{print $1}' | sort | uniq -c | sort -nr | head

Shows whether a single IP or bot group is consuming the pool.

04
Safe solution order

Steps to safely resolve the Plesk 502 and 504 error

Scope test, log matching, service and handler verification, application performance, and final check should be processed in order.

1

Define the scope of the issue

Test different domains on the same server and static files to isolate single site, single PHP version, or global service failure.

curl -skI https://example.com/
2

Find the actual error line in the domain log

In the browser, 502/504 results are unique. The same line in proxy_error_log and error_log nears the root cause, occurring at the same second.

tail -n 150 /var/www/vhosts/system/example.com/logs/proxy_error_log
3

Verify PHP handler and pool

Check in the Plesk panel if the domain is using an existing FPM handler. If a lost socket exists, re-select the handler and apply it.

4

Check service and process capacity

If the PHP-FPM pool is full, RAM usage, average process size, and long-running requests should be measured.

ps -eo pid,user,%cpu,%mem,etime,cmd --sort=-%mem | grep php-fpm | head
5

Only fix the necessary configuration.

Instead of replacing the entire server for a single domain issue, check the web configuration of the related domain name using Plesk repair.

plesk repair web example.com
6

Verify the result and reoccurrence.

Monitor HTTP code, service status, new log entries and resource consumption for at least 15 minutes.

curl -skI https://example.com/ && systemctl is-active nginx
05
Distinction by symptom

Special scenarios and decision trees

Only one site is giving 502

The domain's PHP handler, socket file, proxy_error_log and application extensions are examined. Global Nginx restart is not the first option.

plesk repair web example.com
All Plesk sites are affected

Nginx, Apache, PHP-FPM services, RAM, and the latest package updates are checked globally.

systemctl --failed --no-pager
504 occurring within 60 seconds.

Nginx proxy timeout or PHP max_execution_time limit may be the case. First, determine why the process is taking so long.

time curl -sk https://example.com/ -o /dev/null
Intermittent errors under heavy traffic

Pool capacity, IP addresses sending the most requests, WAF, and rate-limit requirements will be examined.

502 along with database slow

PHP processes can fill the pool by waiting for the SQL response. MariaDB processlist and IO delay are checked.

mysqladmin processlist
iostat -xz 1 3

Absolutely don't

  • Do not lose the proof by restarting all servers without scanning the logs.
  • Do not increase pm.max_children value without doing a RAM account.
  • Do not excessively increase timeout values for normal pages.
  • Do not create the Socket file manually or randomly change its ownership.
  • Do not re-generate the entire web configuration when the issue is on a single domain.
  • Do not terminate heavy processes with kill -9 without identifying the owner and task.

Post-solution verification

  • The main URL returns the expected 200 or redirect code.
  • Nginx, Apache, and PHP-FPM service is active.
  • No new upstream error is occurring in proxy_error_log.
  • The PHP-FPM pool is not reaching the max_children limit continuously.
  • RAM and load values remain balanced.
  • The error does not recur during periods of intense traffic and cron activity.
06
Official technical resources

cPanel and manufacturer documentation

07
Internal SEO content set

Related cPanel and server error solutions

08
Frequently asked questions

Plesk 502 and 504 Error Curiosities about

What is the difference between Plesk 502 and 504?

502 indicates that no valid response was received from the backend, while 504 indicates that the response exceeded the time limit. Although both errors may have the same root cause, the log message shows a different solution layer.

Does restarting Nginx permanently solve the problem?

The stuck connection can be temporarily cleared. If the lost PHP socket, full pool or slow application continues, the error repeats.

How to resolve the php-fpm.sock not found error?

The selected PHP handler for the domain should be verified and rebuilt via web configuration Plesk to an existing FPM version.

What should pm.max_children be?

There is no fixed number. It should be determined by calculating the available RAM, the average consumption of a PHP process, and the share of other services.

Is it correct to increase timeout for 504?

Control can be increased in report creation-like really long processes. Should not be used to hide slow code or SQL queries on a normal page.

What to do if a single WordPress site returns a 502 error?

The domain log, PHP-FPM pool, extensions, wp-cron, external API calls, and database queries should be checked.

Does Plesk repair web data delete?

It checks and re-generates web aspect configuration files; however, a current backup and command output should be obtained before each production server repair.

EKA SOFTWARE AND INFORMATION SYSTEMS

Let's fix the error on your server permanently

By analyzing cPanel, WHM, CloudLinux, LiteSpeed, MariaDB, Exim and security layers together, we fix the root cause of the failure instead of just removing the service.

Get Server Support WhatsApp
Top