Close Menu
    Facebook X (Twitter) Instagram
    • Articles
    • How it Works
    • Our Story
    • Contact Us
    Facebook X (Twitter) Instagram Pinterest Vimeo
    IT Beginner
    • Home
    • Blog
      • Happiness
      • Productivity
      • Leadership
    • About us
    • Contact us
    IT Beginner
    Tips – Tricks

    How to fix nginx an upstream response is buffered to a temporary file error

    05/08/2017No Comments2 Mins Read

    After running Nginx for a while. You can read how I install LEMP server with Linux, Nginx, PHP-FPM, and MySQL on Centos. I got tons of warn logs from nginx on Centos an upstream response is buffered to a temporary file which I don’t like to see. The problem is that I didn’t set fastcgi_buffer for nginx so nginx gives out warn upstream response is buffered to a temporary file /var/cache/nginx/fastcgi_temp/.

    To view Nginx’s error log

    # cat /var/log/nginx/error.log

    There are many an upstream response is buffered to a temporary file /var/cache/nginx/fastcgi_temp/ warn logs from forum.namhuy.net. The warning messages means response was buffered to disk. It’s not that important problem but I don’t want to get any kind of error. You can disable disk buffering with “fastcgi_max_temp_file 0″ in your .conf file or set fastcgi_buffers and fastcgi_buffer_size

    2014/05/10 03:56:06 [warn] 1483#0: *144520 an upstream response is buffered to a temporary file /var/cache/nginx/fastcgi_temp/5/78/0000003785 while reading upstream, client: 54.86.133.62, server: forum.namhuy.net, request: "GET /style.php?id=1&lang=en&sid=69475f2bd936d3e96ef925ce546a79c9 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "forum.namhuy.net", referrer: "http://forum.namhuy.net/viewforum.php?f=3&sid=74d333aafeefe7332a418519e8b03277"
    2014/05/10 03:56:28 [warn] 1483#0: *144518 an upstream response is buffered to a temporary file /var/cache/nginx/fastcgi_temp/6/78/0000003786 while reading upstream, client: 54.86.133.62, server: forum.namhuy.net, request: "GET /style.php?id=1&lang=en HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "forum.namhuy.net", referrer: "http://forum.namhuy.net/posting.php?mode=post&f=3&sid=69475f2bd936d3e96ef925ce546a79c9"
    2014/05/10 03:57:40 [warn] 1483#0: *144673 an upstream response is buffered to a temporary file /var/cache/nginx/fastcgi_temp/7/78/0000003787 while reading upstream, client: 198.204.244.53, server: forum.namhuy.net, request: "GET /style.php?id=1&lang=en&sid=b70a193e6808fb2183ac1c0228097227 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "forum.namhuy.net", referrer: "http://forum.namhuy.net/viewforum.php?f=2&sid=74d333aafeefe7332a418519e8b03277"
    2014/05/10 03:58:06 [warn] 6276#0: *37 an upstream response is buffered to a temporary file /var/cache/nginx/fastcgi_temp/1/00/0000000001 while reading upstream, client: 198.204.244.53, server: forum.namhuy.net, request: "GET /style.php?id=1&lang=en HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "forum.namhuy.net", referrer: "http://forum.namhuy.net/viewtopic.php?f=2&t=2&sid=b70a193e6808fb2183ac1c0228097227"

    To disable fastcgi disk buffering

    # nano /etc/nginx/conf.d/default.conf

    and add this line to location ~ \.php$ { fastcgi configurations }

    fastcgi_max_temp_file 0;

    You should have something like this

         location ~ \.php$ {

            root           /usr/share/nginx/html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_max_temp_file 0;
            include        fastcgi_params;
        }

    To set fastcgi_buffer_size and fastcgi_buffer

    # nano /etc/nginx/conf.d/default.conf

    and add this two lines to location ~ \.php$ { fastcgi configurations }

    fastcgi_buffer_size 4K;
    fastcgi_buffers 64 4k;
    You should have something look like this
        location ~ \.php$ {
            root           /usr/share/nginx/html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_max_temp_file 0;
            fastcgi_buffer_size 4K;
            fastcgi_buffers 64 4k;
            include        fastcgi_params;
        }
    Fastcgi buffer will store responses up to 4K+64*4K=260K in memory.
    fastcgi_buffer
    Previous ArticleOptimize WordPress with Nginx
    Next Article What Makes Linux the Most Adopted Operating System

    Related Posts

    Tips – Tricks

    Optimize WordPress with Nginx

    04/08/2017
    Security

    How to secure Apache HTTP Web Server

    29/07/2017
    Tips – Tricks

    Browse web in linux via terminal with w3m and xterm

    29/07/2017
    Subscribe
    Notify of
    guest

    guest

    This site uses Akismet to reduce spam. Learn how your comment data is processed.

    0 Comments
    Oldest
    Newest Most Voted
    Inline Feedbacks
    View all comments
    • Productivity
    • Leadership

    No posts

    No posts

    Subscribe to Newsletter
    Our Socials
    • Instagram
    • Facebook
    • Twitter
    • YouTube
    • LinkedIn

    Archives

    • April 2025
    • May 2024
    • March 2023
    • July 2022
    • March 2022
    • July 2020
    • January 2019
    • August 2018
    • July 2018
    • August 2017
    • July 2017
    • September 2016

    Categories

    • Business
    • CCNA 1 Instructor Materials
    • CentOS
    • Database
    • Debian
    • Fedora
    • Firefox
    • Happiness
    • Hardware
    • ICND1 Labs
    • ICND2 Labs
    • Leadership
    • Linux Essentials
    • Linux Mint
    • Marketing
    • My SQL
    • Netflix
    • Networking
    • Productivity
    • Resources
    • Security
    • SEO
    • Server
    • Social Media
    • Software
    • Tips – Tricks
    • Ubuntu
    • Uncategorized
    • User Experience
    • WordPress
    • Xubuntu

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna accumsan in scelerisque.

    Facebook X (Twitter) Instagram Pinterest

    Type above and press Enter to search. Press Esc to cancel.

    wpDiscuz