简体   繁体   中英

nginx: 502 error: connect() failed (111: Connection refused) with vagrant

I'm experiencing 502 gateway errors when accessing my site on 127.0.0.1:8000 Working with Vagrant and ubuntu with nginx, trying to install Magento 2.0. After a lot of bugfixxing I still have this 502 error.

Config:

  • Ubuntu 14.04 (ubuntu/trusty64 box)
  • Php 5.6.18 from ppa
  • Nginx 1.8.1

Error log:

connect() failed (111: Connection refused) while connecting to upstream, client: 10.0.2.2, server: localhost, request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://127.0.0.1:7777", host: "127.0.0.1:8000", referrer: "http://127.0.0.1:8000/"

VagrantFile config: http://pastebin.com/rMSTmwJn

my /etc/php5/pool.d/vagrant.conf (and www.conf) file: http://pastebin.com/hHnFrf55

my /etc/nginx/sites-available/default file: http://pastebin.com/0mwR7CxY

which includes this magento nginx config file: https://github.com/magento/magento2/blob/develop/nginx.conf.sample (no edits)

Also have I edited the user and group in www.conf to 'vagrant'

I'm really stuck on this one. Hope you guys can help! If you need more information, please let me know.

I think the problem is occur in your nginx config. It only serves your localhost, but you are trying to access from physical, or another virtual machine. Try to add public domain name. also add 10.0.2.2 public.domain to client's /etc/hosts file. And change below config's related line as server_name localhost public.domain;

server {
    listen 80;
    server_name localhost public.domain;

    set $MAGE_ROOT /var/www/magento2;
    set $MAGE_MODE developer;

    include /vagrant/magento2/nginx.conf.sample;
}

After some more struggling I found out with php5-fpm -t and nginx -t I had an error in my /etc/php5/pool.d/vagrant.conf file rule 1 (:1). I change vagrant to [vagrant] .

Next I got the following error from php5-fpm -t : Both www.conf and vagrant.conf serve on port :7777. Makes sense, so I changed www.conf to listen :9000 and everything is working! Thanks for the effort.

These answers got me close, but weren't my exact problem.

For those interested I'm using Windows 10 with Vagrant - 1.9.3 (laravel/homestead) box.

I was using this in my nginx config:

fastcgi_pass 127.0.0.1:9000;

I recently changed it to this:

fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM