Nginx - 502 Bad Gateway on Drupal 8

By xngo on April 17, 2021


For a long time, I heard that Nginx is much faster and uses far less memory than Apache. Well, today, I decide to take the plunge and replace Apache with Nginx.

I use the configuration for Drupal from After setting up everything and open the website, I got 502 Bad Gateway error.

I checked the error log and it is showing the following.

2021/04/17 09:28:47 [crit] 8420#8420: *1 connect() to unix:/var/run/php/php7.0-fpm.sock failed (2: No such file or directory) while connecting to upstream, client:, server: spacbus-test, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "spacbus-test"


It turned out that the my configuration file is pointing to the wrong FPM version. I changed fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; to fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;. Then, restart nginx.

About the author

Xuan Ngo is the founder of He currently lives in Montreal, Canada. He loves to write about programming and open source subjects.