0

My original error was alot like this:

nginx configuration for Laravel 4

but after modifying the Nginx config server block heavily from advice from multiple forum topics I either get the same error in which the first page is displayed, but any link using a route returns 404, or I get a 502.

/nginx/sites-available/default:

server { listen 80; server_name sub.domain.com; set $root_path '/usr/share/nginx/html/laravel/public'; root $root_path; index index.php index.html index.htm; try_files $uri $uri/ @rewrite; location @rewrite { rewrite ^/(.*)$ /index.php?_url=/$1; } location ~ \.php { fastcgi_pass 127.0.0.1:9000; fastcgi_index /index.php; include /etc/nginx/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; } location ~ /\.ht { deny all; } } 

Error Log:

2014/01/22 16:51:12 [error] 14274#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: xxx.xxx.xxx.xxx, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "xxx.xxx.xxx.xxx"

4
  • do you have an /etc/php5/fpm/pools/ folder ? Commented Jan 22, 2014 at 20:59
  • I have /etc/php5/fpm/pool.d/www.conf @MohammadAbuShady Commented Jan 22, 2014 at 22:14
  • look inside it for a line that says listen, you'll find 2, but only 1 will be uncommented, what does it say ? Commented Jan 23, 2014 at 4:03
  • listen = /var/run/php5-fpm.sock @MohammadAbuShady Commented Jan 23, 2014 at 7:49

1 Answer 1

3

See your issue is that your php isn't actually listening to port 9000, try replacing

fastcgi_pass 127.0.0.1:9000; 

with this

fastcgi_pass unix:/var/run/php5-fpm.sock 

Then reload nginx

sudo service nginx reload 

Your 502 will be gone

Sign up to request clarification or add additional context in comments.

4 Comments

'2014/01/23 20:21:46 [error] 14274#0: *112 connect() failed (111: Connection refused) while connecting to upstream, client: xxx.xxx.xxx.xxx, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "xxx.xxx.xxx.xxx"' @MohammadAbuShady
I'm not sure exactly what I mistyped, but after your inital answer I started to get 403 errors as well. Copied the code from this answer stackoverflow.com/questions/19285355/… Then looked at the differences carefully and fastcgi_pass unix:/var/run/php5-fpm.sock was definitely in there.
I got the same error message on laravel forge. For me just rebooting the server worked.
@AlexanderTaubenkorb probably you had the php service not running, and rebooting started it.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.