By lordcase
I have installed the whole LEMP stack sucessfully on my Centos 8 droplet, everything checks out. I have a DB, I am running php woth php-fpm, all is swell.
Except that I have created two new server blocks and there whenever I try to access a php file through a broswer, I get a 502 Bad Gateway error.
I have these configs for the server blocks:
server {
listen 443;
listen [::]:443;
root /usr/share/nginx/lilla.lordcase.dev;
location / {
index index.html index.htm index.php;
}
server_name lilla.lordcase.dev;
access_log /var/log/nginx/lilla.lordcase.dev.access.log;
error_log /var/log/nginx/lilla.lordcase.dev.error.log;
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
ssl_certificate /etc/letsencrypt/live/lordcase.dev/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/lordcase.dev/privkey.pem; # managed by Certbot
}
The error in the log file is: 2020/07/08 19:33:02 [error] 571#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 176.63.18.177, server: lilla.lordcase.dev, request: “GET /info.php HTTP/1.1”, upstream: “fastcgi://127.0.0.1:9000”, host: “lilla.lordcase.dev”
I have restarted all services, and as I said, on the primary (original) server block php files are parsed perfectly. ANy ideas?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
whats the output of command ss -ntlp ?
You should see the php-fpm service running with port 9000
Well, actually I don’t.
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 0.0.0.0:111 0.0.0.0:*
LISTEN 0 128 0.0.0.0:80 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 0.0.0.0:443 0.0.0.0:*
LISTEN 0 80 :3306 :
LISTEN 0 128 [::]:111 [::]:
LISTEN 0 128 [::]:80 [::]:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 128 [::]:443 [::]:*
Strange, because then how is it possible that on the other “virtual host” php is parsed perfectly?
Heya,
An update on an older topic but I think it can be beneficial for anyone finding it.
The error connect() failed (111: Connection refused) while connecting to upstream suggests an issue with the application rather than Nginx.
In that case, what I recommend is to check the application logs rather than focus your attention on Nginx. 99% It’s due to a misconfiguration or a code-error.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.