Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Site not coming online after rebooting host: 502 Bad Gateway and PHP Socket Error (Workaround available) #29

Closed
remingm opened this issue Feb 23, 2021 · 10 comments
Assignees
Labels
bug Something isn't working

Comments

@remingm
Copy link

remingm commented Feb 23, 2021

Hi Leon, thanks for making this. I found Lokl via reddit and it's perfect for my use case. Using lokl-cli I created a site, exported it to static files, and hosted it. After a computer reboot I attempted to edit the site with the cli, but received "502 Bad Gateway" in the browser. Examining the docker logs, i found this error:

2021/02/23 03:37:47 [crit] 9#9: *1 connect() to unix:/var/run/php7-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 172.17.0.1, server: , request: "HEAD / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php7-fpm.sock:", host: "localhost:4935"

I'm using the PHP 7 image because of the Lokl release notes: "Static HTML Output not working for the PHP 8 image".

lokl/lokl:php7-5.0.0-rc1, Docker 20.10.2, MacOS Catalina.

I'm looking at potential solutions on StackOverflow, but I'm a ML developer and web dev/PHP is not my area of expertise. https://stackoverflow.com/questions/51158830/nginx-connect-to-unix-var-run-php7-2-fpm-sock-failed-2-no-such-file-or-dir/51159313

Should I just use the PHP8 image instead? Thanks for your time.

@leonstafford
Copy link
Contributor

Hi @remingm,

Thanks for using it! There's only a few people I've talked to so far who have tried it out, so this is great to hear from another one!

Let's see if we can figure out what's going on.

I'm just going to spin up a new PHP 7 image and try to replicate, then come back with more info or steps to try and figure this out on your machine.

@leonstafford
Copy link
Contributor

@remingm, good news, I was able to reproduce the issue! Bad news, looks like a bug of some kind. I'm playing around with it now to pinpoint, with a few ideas...

@leonstafford
Copy link
Contributor

This looks like the result of the issue:

tail -f /usr/logs/php-fpm/php-fpm.log
[23-Feb-2021 11:06:32] ERROR: [pool www] please specify user and group other than root
[23-Feb-2021 11:06:32] ERROR: FPM initialization failed

Let me poke around in that area and see why it's not forcing nginx to run as root user as during other times...

@leonstafford
Copy link
Contributor

OK, can at least recover from this state while I figure out the greater cause:

  • use Lokl's CLI wizard to SSH into the container
  • restart the PHP service as root: php-fpm7 -R
  • run the MySQL service as root: mysqld -u root

Site should now load fine in browser.

I'll double check above workaround in a brand new image to be sure and then will need some more time to look at fixing the issue properly.

@leonstafford leonstafford added the bug Something isn't working label Feb 23, 2021
@leonstafford leonstafford changed the title 502 Bad Gateway and PHP Socket Error Site not coming online after rebooting host: 502 Bad Gateway and PHP Socket Error Feb 23, 2021
@leonstafford leonstafford self-assigned this Feb 23, 2021
@leonstafford
Copy link
Contributor

@remingm, confirmed the above mentioned workaround works. The second line won't return control back to the terminal when run, so can close that terminal window after running and confirming site loads in your browser.

Please let me know if any issues applying that workaround and await a proper fix from me.

I didn't check the same thing on the php8 images, but if you try before me, please report back. I am pretty sure I had checked the images after rebooting before I published that last release, but maybe I changed something that broke things after last complete test. Anyway, I'll should have that sorted next session I spend on Lokl's development.

@remingm
Copy link
Author

remingm commented Feb 23, 2021

Thanks for the quick response. The workaround works.

I just spun up a new php8 image. After docker restart [container] I experienced the same issue, but the workaround restored browser access again.

@phlash
Copy link

phlash commented Feb 23, 2021

[edited for clarity in wording!]
Confirmed here too - php8, no funny settings etc. Works fine on creation, needs workaround after restart of docker container.

I have had a play with /run.sh, which appears to start nginx but nothing else on third and subsequent runs. Inserting the following before the call to nginx appears to fix the issue:

php-fpm8 -R
/usr/bin/mysqld --user=root &

@leonstafford leonstafford pinned this issue Feb 27, 2021
@leonstafford leonstafford changed the title Site not coming online after rebooting host: 502 Bad Gateway and PHP Socket Error Site not coming online after rebooting host: 502 Bad Gateway and PHP Socket Error (Workaround available) Apr 22, 2021
@insign
Copy link

insign commented May 10, 2021

@phlash great fix. Worked for me very fine. I used vim to edit, so, how can I get back to the terminal?

@leonstafford
Copy link
Contributor

@insign - how to exit Vim is a very common meme, so forgive me if you're joking, but:

: + wq to write and quit

@leonstafford
Copy link
Contributor

Thanks everyone for their patience with this major issue!

And thanks @phlash for supplying the fix. I've stop/started a new site a few times, including rebooting and looks good.

I'll close this issue once new release published and Lokl homepage updated with new command using latest release

@leonstafford leonstafford unpinned this issue Oct 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants