Nginx: Bad Gateway 502 error

Absinthe62 asked:

I am running Nginx with PHP5-FPM on Amazon EC2 on Ubuntu 12.04 64-bit. I get a bad gateway error whenever I got to my site. I know that it is a configuration issue but I am not sure what is badly configured.

My error log:

2012/11/17 05:29:19 [error] 9519#0: *4 open() “/var/www/growyourbutt.com/robots.txt” failed (2: No such file or directory), client: 131.253.41.146, server: growyourbut$
2012/11/17 05:29:19 [error] 9519#0: *5 open() “/var/www/growyourbutt.com/wp-content/themes/wp-bold107/images/facebook.png” failed (2: No such file or directory), clien$
2012/11/17 05:30:36 [error] 9519#0: *6 “/var/www/growyourbutt.com/tag/brazilian-butt-lift-surgery-cost/index.php” is not found (2: No such file or directory), client: $
2012/11/17 05:31:56 [error] 9519#0: *7 connect() failed (111: Connection refused) while connecting to upstream, client: 67.85.186.145, server: growyourbutt.com, reques$
2012/11/17 05:31:56 [error] 9519#0: *10 connect() failed (111: Connection refused) while connecting to upstream, client: 188.138.0.168, server: growyourbutt.com, reque$
2012/11/17 05:31:57 [error] 9519#0: *12 connect() failed (111: Connection refused) while connecting to upstream, client: 188.138.0.168, server: growyourbutt.com, reque$
2012/11/17 05:32:00 [error] 9519#0: *7 connect() failed (111: Connection refused) while connecting to upstream, client: 67.85.186.145, server: growyourbutt.com, reques$
2012/11/17 05:33:37 [error] 9519#0: *15 connect() failed (111: Connection refused) while connecting to upstream, client: 67.85.186.145, server: growyourbutt.com, reque$
2012/11/17 05:33:44 [error] 9519#0: *18 connect() failed (111: Connection refused) while connecting to upstream, client: 67.85.186.145, server: growyourbutt.com, reque$
2012/11/17 05:33:44 [error] 9519#0: *18 open() “/var/www/growyourbutt.com/favicon.ico” failed (2: No such file or directory), client: 67.85.186.145, server: growyourbu$
2012/11/17 05:35:29 [error] 9519#0: *20 connect() failed (111: Connection refused) while connecting to upstream, client: 220.181.108.160, server: growyourbutt.com, req$
2012/11/17 05:35:45 [error] 9519#0: *22 connect() failed (111: Connection refused) while connecting to upstream, client: 123.125.71.111, server: growyourbutt.com, requ$

My nginx.conf:

ser www-data;
worker_processes 4;
pid /run/nginx.pid;

events {
worker_connections 768;
# multi_accept on;
}

http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;

##
# Basic Settings
##

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    server_tokens off;

    server_names_hash_bucket_size 64;
    server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    port_in_redirect off;

server_tokens off;

    server_names_hash_bucket_size 64;
    server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    port_in_redirect off;
    ##
    # Logging Settings
    ##

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    ##
    # Gzip Settings
    ##

gzip on;
gzip_disable “msie6”;

    # gzip_vary on;
    # gzip_proxied any;
    # gzip_comp_level 6;
    # gzip_buffers 16 8k;
    # gzip_http_version 1.1;
    # gzip_types text/plain text/css application/json application/x-javascr$

    ##
    # nginx-naxsi config
    ##
    # Uncomment it if you installed nginx-naxsi
    ##

    #include /etc/nginx/naxsi_core.rules;

    ##

include /etc/nginx/conf.d/.conf;
include /etc/nginx/sites-enabled/
;
}

If anyone can help me figure this out, I will really appreciate it.

My answer:


php-fpm isn’t running. Restart the service.


View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.