Nginx/FastCGI return 500 Internal Server Error when sending many requests

Posted April 4, 2017 23.1k views
NginxUbuntu 16.04

I’ve deployed Asp.Net Webservice to connect to Riak on Ubuntu 16.04 using latest version of Mono, FastCGI and Nginx. The Webservice works fine when I access it on my browser. It also works fine if I send one request and wait for response before sending another request. The problem occur when I tried to send many requests at the same time (using www class in Unity3D Engine). From my testing I can only send request up to 7 requests simultaneously. More than that and Nginx/FastCGI would return 500 Internal Server Error. Log file has an access log for this error request.

x.x.x.x - - [27/Mar/2017:10:35:20 +0000] “POST /RiakService.asmx/GetValueMapBucket HTTP/1.1” 500 53 “-” “UnityPlayer/5.5.2f1 (” “-”

But there is no error log in /var/log/nginx/error.log relate to this error request. So, it doesn’t help at all. My Webservice code shouldn’t have any problem because I’ve tested sending 10 requests on xsp4 instead of Nginx/FastCGI. It works correctly. Every request return correct result and no error. Is there any configuration in Nginx/FastCGI relate to this behavior? This is my Nginx configuration for proxy server.

server {
location ~.asmx(.) {
fastcgisplitpath_info ^(.+.asmx)(.
fastcgiparam SCRIPTFILENAME $documentroot$fastcgiscriptname;
param PATHINFO $fastcgipathinfo;
include /usr/local/nginx/conf/fastcgi

I tried using debug mode. These are log files when I sent 10 requests. All requests returned 500 Internal Server Error. I’m still a novice in this field. I really appreciate any help.


These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer


From looking at the Mono Docs for NGINX, they recommend a slightly different configuration.

 server {
         listen   80;
         access_log   /var/log/nginx/;
         root /var/www/;

         location / {
                 index index.html index.htm default.aspx Default.aspx;
                 fastcgi_index Default.aspx;
                 include /etc/nginx/fastcgi_params;


fastcgi_param  PATH_INFO          "";
fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;

.. being added to fastcgi_params, or replacing what is already there if those are already set to values other than the above.

The default location of fastcgi_params on Ubuntu is normally /etc/nginx/fastcgi_params unless you have modified it and placed it elsewhere or installed a version of NGINX that isn’t in their repos.

You can further modify the above server block and add error_log to create a log specifically for that block as well. You’d add:

error_log /var/log/nginx/;

.. below or above access_log. Once changes are made, you’d want to reload or restart NGINX.

service nginx reload
service nginx restart


systemctl reload nginx
systemctl restart nginx
  • I just noticed that it was my old configuration and some characters were removed when I posted it. This is my current configuration.

    server {
       error_log /var/log/nginx/riakclient.log debug;
       location ~\.asmx(.*) {
         fastcgi_split_path_info ^(.+\.asmx)(.*)$;
         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
         fastcgi_param PATH_INFO $fastcgi_path_info;
         include /etc/nginx/fastcgi_params;
         #fastcgi_index Default.asmx;

    It’s not the same as in official page because for some reasons the configuration in official pages didn’t work for me. I searched and used this guide instead.

    This configuration works for me. But it doesn’t work if I send many requests at the same time.

    • @nattawitta

      As a general rule, you want to setup a complete server block.

      With the server block you have right now, there’s no specific routing to your domain and it will accept any request on any domain that is pointing to your Droplet’s IP.

      Above the error_log directive, you’d want to add:

          listen 80;
          root /path/to/home;

      … and swap out with your domain, and /path/to/home with the location of the files you’re serving.

      That being said, when removing debug from error_log, something should be getting sent to either:




      The only time you shouldn’t see something being logged to the above error.log is if you’re using a modified NGINX configuration (check /ect/nginx/nginx.conf) and see the error log to a different location.

      As far as NGINX goes, all NGINX is doing here is passing the request for files over to your handler for processing. The issue could range from the application is taking too long to load, to you have too few resources to handle the number of requests (i.e. CPU/RAM), to any other number of issues.

      For example, when an error, such as the one you’re receiving, applies to fastcgi using PHP, the issue is normally with the PHP application/script or PHP-FPM. NGINX is just passing the request over and expecting a response so that it can serve the request based on what it receives.

      The first thing I’d recommend doing is making sure logging is also setup for your app so that when you receive a request, something is logged. You’d then take a look at the application logs as well as that of the server to see if there’s more to the error.