Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails connect()到unix:/var/run/unicorn.sock在连接到上游时失败(111:连接被拒绝)_Ruby On Rails_Ruby_Nginx_Digital Ocean_Unicorn - Fatal编程技术网

Ruby on rails connect()到unix:/var/run/unicorn.sock在连接到上游时失败(111:连接被拒绝)

Ruby on rails connect()到unix:/var/run/unicorn.sock在连接到上游时失败(111:连接被拒绝),ruby-on-rails,ruby,nginx,digital-ocean,unicorn,Ruby On Rails,Ruby,Nginx,Digital Ocean,Unicorn,我遵循RubyonRails一键式应用部署。数据库做得很好,即使我检查rails控制台一切正常 017/02/26 15:34:17 [error] 18564#0: *31 connect() to unix:/var/run/unicorn.sock failed (111: Connection refused) while connecting to upstream, client: 121.52.156.57, server: _, request: "GET / HTTP/1.1"

我遵循RubyonRails一键式应用部署。数据库做得很好,即使我检查rails控制台一切正常

017/02/26 15:34:17 [error] 18564#0: *31 connect() to unix:/var/run/unicorn.sock failed (111: Connection refused) while connecting to upstream, client: 121.52.156.57, server: _, request: "GET / HTTP/1.1", upstream: "http://unix:/var/run/unicorn.sock:/", host: "188.166.157.124"
2017/02/26 15:35:42 [error] 32360#0: *1 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 119.155.34.115, server: _, request: "GET / HTTP/1.1", upstream: "http://unix:/var/run/unicorn.sock/", host: "188.166.157.124"
2017/02/26 15:42:38 [error] 6296#0: *1 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 119.152.140.90, server: _, request: "GET / HTTP/1.1", upstream: "http://unix:/var/run/unicorn.sock/", host: "188.166.157.124"
uncorn.conf是

listen "unix:/var/run/unicorn.sock"
worker_processes 4
user "rails"
working_directory "/home/rails/company_startup"
pid "/var/run/unicorn.pid"
stderr_path "/var/log/unicorn/unicorn.log"
stdout_path "/var/log/unicorn/unicorn.log"
nginx是

upstream app_server {
server unix:/var/run/unicorn.sock fail_timeout=0;
}

server {
listen   80;
root /home/rails/nehbor-webserver/public;
server_name _;
index index.htm index.html;
client_max_body_size 1M;
location / {
        try_files $uri/index.html $uri.html $uri @app;
}

location ~* ^.+\.(jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|mp3|flv|mpeg|avi)$ {
                try_files $uri @app;
        }

 location @app {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_pass http://app_server;
}
}
根据,我认为您应该从配置中的
listen
方法中删除
unix
部分,并将其更改为
listen”/var/run/unicorn.sock“


简言之,nginx正试图重新定向到您的应用程序,但它无法。除了基本配置和结构之外,我认为最常见的问题是:

  • 港口
  • 插座
  • 对我来说(使用aws ec2),我使用的是一个通过dns注册表上的cname记录链接的域。ip已更改,更改了域服务器名称,我的记录未更新。我刚刚将它从cname记录名更改为我的新弹性域名
选中此项,它显示要添加unix
listen 3000 # listen to port 3000 on all TCP interfaces
listen "127.0.0.1:3000"  # listen to port 3000 on the loopback interface
listen "/path/to/.unicorn.sock" # listen on the given Unix domain socket
listen "[::1]:3000" # listen to port 3000 on the IPv6 loopback interface