Error 502 Bad Gateway on nginx

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Error 502 Bad Gateway on nginx

xt3627216
Error 502 Bad Gateway on nginx and php-fpm
Posted by: mmpl

I can't start php7-fpm in supervisor. The error log:

unable to bind listening socket for address '127.0.0.1:9000': Address in >
use (98)

In browser:

localhost:8090 is error: 502 Bad Gateway

netstat -tulnp

tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 13/nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 13/nginx
tcp 0 0 0.0.0.0:8090 0.0.0.0:* LISTEN 13/nginx
tcp 0 0 :::3000 :::* LISTEN 11/node
tcp 0 0 :::7000 :::* LISTEN 10/node
ps aux

/ # ps aux
PID USER TIME COMMAND
1 root 0:00 {bootloader} /bin/sh /boot/bootloader
8 root 0:01 {supervisord} /usr/bin/python2 /usr/bin/supervisord
62 root 0:00 /bin/sh
92 root 0:00 nginx: master process /usr/sbin/nginx
93 root 0:00 nginx: worker process
94 root 0:00 nginx: worker process
122 root 0:00 ps aux
php-fpm.d/www/conf

[www]

user = nobody
group = nobody

listen = 127.0.0.1:9000

pm = dynamic

pm.max_children = 5

pm.start_servers = 2

pm.min_spare_servers = 1

pm.max_spare_servers = 3
/etc/nginx/sites-enabled/page1

server {
listen 8090;
root /usr/bin;
server_name localhost;
access_log /dev/null;
error_log /dev/null;

location / {
proxy_pass <a href="http://127.0.0.0:7000;">http://127.0.0.0:7000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Fowarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Fowarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;

try_files $uri $uri/ =404;
}

location ~ \.(gif) {
root /var/lib;
}

}
/etc/nginx/sites-enabled/page2

server {
server_name localhost;
root /www;
index index.php;
access_log /dev/null;
error_log /dev/null;

client_max_body_size 100M;
fastcgi_read_timeout 1800;

location / {
try_files $uri $uri/ /index.php$query_string;
}

location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
access_log off;
}

location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
}
}
Where is error? I don't just any idea.

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,285807,285807#msg-285807

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Error 502 Bad Gateway on nginx

Lahiru Prasad
Hi,
     Does nc -l 9000 gives the same bind error ?
If so, better to check netstat for :9000 sockets with all status, like netstat -anp | grep :9000
to get an idea.

Regards,
Lahiru Prasad.

On Mon, Oct 7, 2019 at 11:38 AM mmpl <[hidden email]> wrote:
Error 502 Bad Gateway on nginx and php-fpm
Posted by: mmpl

I can't start php7-fpm in supervisor. The error log:

unable to bind listening socket for address '127.0.0.1:9000': Address in >
use (98)

In browser:

localhost:8090 is error: 502 Bad Gateway

netstat -tulnp

tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 13/nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 13/nginx
tcp 0 0 0.0.0.0:8090 0.0.0.0:* LISTEN 13/nginx
tcp 0 0 :::3000 :::* LISTEN 11/node
tcp 0 0 :::7000 :::* LISTEN 10/node
ps aux

/ # ps aux
PID USER TIME COMMAND
1 root 0:00 {bootloader} /bin/sh /boot/bootloader
8 root 0:01 {supervisord} /usr/bin/python2 /usr/bin/supervisord
62 root 0:00 /bin/sh
92 root 0:00 nginx: master process /usr/sbin/nginx
93 root 0:00 nginx: worker process
94 root 0:00 nginx: worker process
122 root 0:00 ps aux
php-fpm.d/www/conf

[www]

user = nobody
group = nobody

listen = 127.0.0.1:9000

pm = dynamic

pm.max_children = 5

pm.start_servers = 2

pm.min_spare_servers = 1

pm.max_spare_servers = 3
/etc/nginx/sites-enabled/page1

server {
listen 8090;
root /usr/bin;
server_name localhost;
access_log /dev/null;
error_log /dev/null;

location / {
proxy_pass http://127.0.0.0:7000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Fowarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Fowarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;

try_files $uri $uri/ =404;
}

location ~ \.(gif) {
root /var/lib;
}

}
/etc/nginx/sites-enabled/page2

server {
server_name localhost;
root /www;
index index.php;
access_log /dev/null;
error_log /dev/null;

client_max_body_size 100M;
fastcgi_read_timeout 1800;

location / {
try_files $uri $uri/ /index.php$query_string;
}

location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
access_log off;
}

location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
}
}
Where is error? I don't just any idea.

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,285807,285807#msg-285807

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx