Ponzio Pilato
Ponzio Pilato

Reputation: 325

Laravel Valet 504 Gateway Time-out nginx/1.19.6 after 60 seconds

I followed all the instructions here:

https://github.com/laravel/valet/issues/315

I noticed a better performance, especially after updating the PM pool configuration for Valet. (Now some execution started to be completed because the time needed is less than 60 seconds).

but with longer executions, still, the error is showed after 60 seconds.

Actually my conf. files are like that:

valet-fpm.conf

; FPM pool configuration for Valet

[valet]
user = xxx
group = staff
listen = /Users/xxx/.config/valet/valet.sock
listen.owner = xxx
listen.group = staff
listen.mode = 0777

;; When uncommented, the following values will take precedence over settings declared elsewhere
;php_admin_value[memory_limit] = 512M
;php_admin_value[upload_max_filesize] = 128M
;php_admin_value[post_max_size] = 128M

;php_admin_value[error_log] = /Users/xxx/.config/valet/Log/php-fpm.log
;php_admin_flag[log_errors] = on


;; Note: increasing these values will increase the demand on your CPU and RAM resources
pm = dynamic
;pm.max_children = 5
;pm.start_servers = 2
;pm.min_spare_servers = 1
;pm.max_spare_servers = 3

pm.max_children = 200
pm.start_servers = 20
pm.min_spare_servers = 10
pm.max_spare_servers = 20
pm.process_idle_timeout = 10s
pm.max_requests = 500

valet.conf

server {
    listen 127.0.0.1:80 default_server;
    root /;
    charset utf-8;
    client_max_body_size 128M;

    location /41c270e4-5535-4daa-b23e-c269744c2f45/ {
        internal;
        alias /;
        try_files $uri $uri/;
    }

    location / {
        rewrite ^ "/Users/xxx/.composer/vendor/laravel/valet/server.php" last;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    error_log "/Users/xxx/.config/valet/Log/nginx-error.log";

    error_page 404 "/Users/xxx/.composer/vendor/laravel/valet/server.php";

    location ~ [^/]\.php(/|$) {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass "unix:/Users/xxx/.config/valet/valet.sock";
        fastcgi_index "/Users/xxx/.composer/vendor/laravel/valet/server.php";
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME "/Users/xxx/.composer/vendor/laravel/valet/server.php";
        fastcgi_param PATH_INFO $fastcgi_path_info;

        proxy_connect_timeout       3000;
        proxy_send_timeout          3000;
        proxy_read_timeout          3000;
        send_timeout                3000;
    }

    location ~ /\.ht {
        deny all;
    }
}

nginx.conf

user "xxx" staff;
#worker_processes auto;
worker_processes 8;

events {
    worker_connections  1024;
}

http {
    include mime.types;
    default_type  application/octet-stream;

    sendfile on;
    keepalive_timeout  650;
    types_hash_max_size 2048;

    client_max_body_size 1024M;


    client_header_timeout 3000;
    client_body_timeout 3000;
    fastcgi_read_timeout 3000;
    fastcgi_buffers 8 128k;
    fastcgi_buffer_size 128k;



    server_names_hash_bucket_size 128;

    ssi on;

    gzip  on;
    gzip_comp_level 5;
    gzip_min_length 256;
    gzip_proxied any;
    gzip_vary on;
    gzip_types
    application/atom+xml
    application/javascript
    application/json
    application/rss+xml
    application/vnd.ms-fontobject
    application/x-font-ttf
    application/x-web-app-manifest+json
    application/xhtml+xml
    application/xml
    font/opentype
    image/svg+xml
    image/x-icon
    text/css
    text/plain
    text/x-component;

    include "/Users/xxx/.config/valet/Nginx/*";
    include servers/*;
    include valet/valet.conf;
}

What else should I modify? Thanks in advance

Upvotes: 2

Views: 8295

Answers (1)

Nyongesa Ignatius
Nyongesa Ignatius

Reputation: 121

In your Nginx configuration make sure you add this under location ~ \.php$ block

location ~ \.php$ {
    #...
    #fixes timeouts
    fastcgi_read_timeout 600;
}

Upvotes: 2

Related Questions