Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

net::ERR_CONNECTION_REFUSED with Nginx and Laravel 5

I have just installed a fresh copy of Laravel 5 into /var/www.

When I browse to the server I get net::ERR_CONNECTION_REFUSED.

My Nginx config (default) is:

server {
    listen 80;

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

    server_name _;

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

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

}

Any idea what I'm doing wrong?


I am also confused about sites-enabled and sites-available. Where should default actually go?

I have moved default from sites-available to sites-enabled and I am now getting a 403 with "Access denied".

like image 283
imperium2335 Avatar asked Sep 28 '22 04:09

imperium2335


1 Answers

You probably got net::ERR_CONNECTION_REFUSED because you hadn't told nginx what port to listen on (note the listen 80 line in your config file), so you were trying to a port that wasn't open - hence the connection refused error.

As for sites-available vs sites-enabled, that's a Debian/Ubuntu thing to make sites easier to manage - you can have many sites configured in sites-available, but only run specific ones by adding a link in sites-enabled pointing at the respective config file in sites-available.

As an example, my sites-enabled folder has

lrwxrwxrwx 1 root root 40 Feb  8 07:53 site.net -> /etc/nginx/sites-available/site.net

No copying, just a link to sites-available.


For your 403 error, look in your error log for what precisely is failing. It should be located at /var/log/nginx/error.log - look for error_log in your main conf file to get the exact location.

like image 146
Kyle Avatar answered Oct 02 '22 13:10

Kyle