Fix "504 Gateway Timeout" When Using Laravel Valet

If you get a 504 Gateway Timeout when using Laravel Valet and you want to increate the timeout, you can do this by modifying the file /usr/local/etc/nginx/valet/valet.conf:

nano /usr/local/etc/nginx/valet/valet.conf

Now, add these lines:

proxy_connect_timeout       600;
proxy_send_timeout          600;
proxy_read_timeout          600;
send_timeout                600;
fastcgi_read_timeout        300;
fastcgi_buffers 8 128k;
fastcgi_buffer_size         256k;

To this block:

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

        # ENTER HERE

After saving the file, restart Laravel Valet:

valet restart

Now, the required timeouts should be increased.