502 Bad Gateway

I just setup Wordpress on Caddyserver. It worked WONDERFULLY. Except, I didn’t have the permissions to change anything because it was ll owned by root. it was driving me nuts having to go back and forth between root and my home user. So, I deleted the project and started again. Wordpress kept wanting access to my ftp server and that was annoying as crap.

I created a folder in my home directory called: site.
As Wordpress was already running before, I have PHP and MySQL installed. However, when I disable fastcgi, the static text loads fine.
I uploaded the wp files there.
I also dropped the wp database from MySQL and created a new one.
I created a new Caddyfile, just like the old one.
I have given caddy permission to run on port 80 so I can run it without sudo.

Whenever I load the site, I get a 502 Bad Gateway error.

Here is my Caddyfile:

smashindex.com {
root /home/jesse/site/
fastcgi / /var/run/php7.0-fpm.sock php {
        ext     .php
        split   .php
        index   index.php

Now that I’ve played around a bit, I’m getting this error: dial unix /var/run/php7.0-fpm.sock: connect: no such file or directory

So, I found my solution: The listening path in Caddy’s documentation didn’t match my system’s listening path for php.

My listening path was incorrect: server - 502 Bad Gateway nginx php7 fpm - Ask Ubuntu
Also: nginx and php-fpm socket owner - Stack Overflow
^ This was my original intent.

Glad you got it figured out! Thanks for coming back to post the solution to help other future readers.

I had the same problem, but with a different cause: My php-fpm socket had the wrong permissions.

Suggestion: I noticed that the cgi plugin logs errors to stdout (with -log stdout). Would it be possible to make FastCGI do the same thing? It would make this much easier to debug.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.