Solved – 504 Gateway Timeout Error In Nginx Web Server

-Open your nginx.conf file located in /etc/nginx directory

-Add this below piece of code under http { section

client_header_timeout 3000;
client_body_timeout 3000;
fastcgi_read_timeout 3000;
client_max_body_size 32m;
fastcgi_buffers 8 128k;
fastcgi_buffer_size 128k;

Note - If its already present , change the values according.

That’s it. Reload Nginx and php5-fpm.

service nginx reload

service php5-fpm reload

If the error persists ( which is rare ), consider increasing the values.

  • http://www.gaptekupdate.com/ Gaptek Update

    Hoah, to large timeout i see there. i think 120 – 180 is enough

  • marty

    i dont have /etc/nginx/nginx.conf
    i just have etc/apache2
    wher is the nginx directory. i already install it. byt wheree?

    • http://www.alphagenetica.com Drew

      @marty you don’t even have nginx installed… look for apache documentation

    • Arpit Jain

      @marty You have apache web server installed and also try reinstalling nginx web server.

  • SPeed_FANat1c

    when only one client on localhost vagrant loads the page and it waits more then few seconds – fuck it. I need better solution. To find out WHY it is loading so long and others times normally after I restart vagrant

  • Invtr

    That’s a funny solution. That won’t work lol

  • TheDigiLife

    It worked, thanks

  • Marco Marsala

    If nginx is a reverse proxy for Apache (like in all default Plesk >= 11 setup) it won’t work

    • Renner

      Any idea what’s the solution in this case ?

  • http://natanfelles.github.io/ Natan Felles

    It is always usefull base for me, since 2013. Thanks.

  • dezza

    Ok so the solution is to crank up all values to their maximum. Sounds reasonable. (NOT) haha.