Upstream service php-fpm is up and running but reports {"errors": {"status_code": 502,"status": "php-fpm server is down"}}

Francis Daly francis at
Fri Jan 6 21:25:54 UTC 2023

On Thu, Jan 05, 2023 at 10:15:34PM +0530, Kaushal Shriyan wrote:

Hi there,

> When I hit for conditions when MySQL DB is down. I
> get the below output and it works as expected.
> {"errors": "MySQL DB Server is down"}
> When I hit for conditions when MySQL DB is up and
> running fine, I get the below output in spite of MySQL DB server being
> fine.
> {"errors": "MySQL DB Server is down"}

Your config is

    location /apis {
        return 500 '{"errors": "MySQL DB Server is down"}';

Whenever you make a request that is handled in that location{}, your
nginx will return that response.

It looks like your nginx is doing what it was told to do.

No part of your config indicates that nginx knows (or cares) whether
MySQL DB is up or down. Does something outside of nginx know that?

Francis Daly        francis at

More information about the nginx mailing list