502 Bad Gateway - Phalcon + Nginx + CentOS7

Hi. I have a digitalocean server running phalcon. But I am not trying to fix my URLs so they are pretty. I had everything working on the default config for Nginx, although I had to go to domain/app/public without rewrites, you know... the "unpretty way."

In an attempt to clean up the urls, so I could go domain.me, i checked out these "installation notes" (https://docs.phalconphp.com/en/latest/reference/nginx.html)

I tried all of the configurations (adjusted for my domain, of course), and came up with errors ranging from a simple text "Access denied" to now "502 Bad Gateway" error.

I am not sure what the problem is, I have checked out other similar threads, and they offer little in the way of relevant guidance that I haven't already tried. I want to clarify that everything is installed and working, prior to my adjusting the nginx config.

Here is my current config:

server { listen 80; server_name localhost;

charset      utf-8;

#access_log  /var/log/nginx/host.access.log  main;

set $root_path '/usr/share/nginx/html/liamhockley-www/hockley_personal/public';

location / {
  root   $root_path;
  index  index.php index.html index.htm;

  # if file exists return it right away
  if (-f $request_filename) {

  # otherwise rewrite it
  if (!-e $request_filename) {
      rewrite ^(.+)$ /index.php?_url=$1 last;

location ~ \.php {
  # try_files    $uri =404;

  fastcgi_index  /index.php;

  include fastcgi_params;
  fastcgi_split_path_info       ^(.+\.php)(/.+)$;
  fastcgi_param PATH_INFO       $fastcgi_path_info;
  fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
  root $root_path;


Start at the log files... http://serverfault.com/questions/433024/how-can-i-debug-nginx-further-than-the-error-log

Ok. Thanks for the response. The log file is showing the following:

2015/08/17 12:39:20 [error] 10214#0: *5 connect() failed (111: Connection refused) while connecting to upstream, client: >XX.XX.XXX.XX, server: XXX.me, request: "GET / HTTP/1.1", upstream: "fastcgi://", host: "XXX.me"

Note: I replaced the ip/domain with XXX.

It appears to be telling me there is a problem with "fastcgi" ? Where would I continue my troubleshooting? Thanks.

Nevermind. I am just going to rebuild my web server from scratch, and look for a more traditional (file based) PHP framework. I don't think this is worth the hassle. Thanks for your help.

The configuration of the nginx when we are new users is a little tricky, but once we got is worth the performance.

Try changing the listen to 8080 and restart nginx


I actually figured that my issue was very likely that I was listening on a unix socket instead of "". I already moved on and decided to use Laravel-Lumen microframework, especially considering this isn't a performance critical application I am working on.

I will certainly look in to this Framework again sometime. Until then, thank you for your help.