# Something I’ve discovered using Valet, monitoring Nginx Logs and changing Nginx Config settings

- Link: https://elliottrichmond.co.uk/something-ive-discovered-using-valet-monitoring-nginx-logs-and-changing-nginx-config-settings/
- Published: 2019-07-02T10:22:40+00:00

I’ve recently moved over to using Valet for local development, it had its ups and
downs and has been a bit of a learning curve as I’m used to using Apache not Nginx
as a web server.

I’m really documenting this as my own handbook but if others can benefit from it
then so be it!

Something that kept tripping me up was where to access the logs to diagnose issues
as they arise, inevitably as developers we have to make tweaks to our settings and
configurations so monitoring the logs when errors occur are essential.

My server was running fine until I updated something, then on certain pages of my
app I was getting a 502 Bad Gateway error! So, first I need to monitor the logs.
Turns out on my local Mac environment the logs for Nginx are in the following folder:

    ```wp-block-code
    /Users/[insert-your-user]/.config/valet/Log
    ```

So from here you can load a terminal and run the following command to monitor the
logs.

    ```wp-block-code
    $ cd /Users/[insert-your-user]/.config/valet/Log
    ```

in this folder, I found a log file called ‘nginx-error.log’

So, now I can run the following command and watch the log whilst refreshing the 
browser to see what gets logged.

    ```wp-block-code
    tail -f nginx-error.log
    ```

This gave me a clue, namely on this line:

    ```wp-block-code
    48289#0: *1 upstream sent too big header while reading response header from upstream, client: 127.0.0.1
    ```

After a little bit of Googling, it turns out I needed to increase the FastCGI buffer
in my Nginx config file which in my case was found at

    ```wp-block-code
    /usr/local/etc/nginx/nginx.conf
    ```

Open that up in your favorite command line editor which for me is currently ‘nano’

    ```wp-block-code
    $ cd /usr/local/etc/nginx
    $ nano nginx.conf
    ```

Add the following

    ```wp-block-code
    fastcgi_buffers 16 16k;
    fastcgi_buffer_size 32k;
    ```

 You will then need to restart valet

    ```wp-block-code
    $ valet restart
    ```

 Now my page loads without the 502 Bad Gateway, so I am happy! 🙂

### Share this:

 * [  Facebook ](https://elliottrichmond.co.uk/something-ive-discovered-using-valet-monitoring-nginx-logs-and-changing-nginx-config-settings/?share=facebook)
 * [  X ](https://elliottrichmond.co.uk/something-ive-discovered-using-valet-monitoring-nginx-logs-and-changing-nginx-config-settings/?share=x)

### Like this:

Like Loading…
