特定路由上的Nginx Bad Gateway错误

I'm using Nginx + PHP-FPM and on some routes I receive a 502 Bad Gateway error. When I dd('test') it will return the text inside the dd(). The text isn't received inside the Controller constructor so the error is probably happening after route dispatching.

When I look at the logs it does return this error:

2015/09/03 13:28:35 [error] 18#0: *1 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 192.168.59.3, server: _, request: "GET /v2/topics/4/timeline HTTP/1.1", upstream: "fastcgi://unix:/run/php5-fpm.sock:", host: "192.168.59.103:8080"

I've added catch_workers_output = yes to the /etc/php5/fpm/pool.d/default.conf file, but nothing changes.

My /etc/php5/fpm/pool.d/default.conf file looks like this:

[default]
user = core
group = core
listen = /run/php5-fpm.sock
listen.owner = core
pm = ondemand
pm.max_children = 4
php_value[max_execution_time] = 120
php_value[post_max_size] = 256M
php_value[upload_max_filesize] = 256M
include = /data/config/php-*.conf
catch_workers_output = yes

My /etc/nginx/host.d/default.conf file looks like this:

server {
        listen          80 default_server;
    listen   [::]:80 default_server ipv6only=on;

    server_name     _;

        root            /www/public;
        index           index.php index.html index.htm;

    location / {
             try_files $uri $uri/ /index.php?$query_string;
        }

    location = /favicon.ico {
         log_not_found off;
    }

        location ~ \.php$ {
             try_files $uri /index.php =404;
             fastcgi_split_path_info ^(.+\.php)(/.+)$;
         fastcgi_pass unix:/run/php5-fpm.sock;
             fastcgi_index index.php;
             fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
             include fastcgi_params;
        }

    rewrite_log on;
        access_log      /var/log/nginx/default_access.log;
        error_log       /var/log/nginx/default_error.log notice;
}

What could be the issue? It's really strange that the error in on specific routes.