(111: Connection refused) while connecting to upstream - Opsworks Rails 4
6,780
Make sure /srv/www/app/shared/sockets/unicorn.sock
has correct rights for the user nginx's worker processes are running with (www-data
in your case).
Related videos on Youtube
Author by
darkcode
Updated on September 18, 2022Comments
-
darkcode over 1 year
I deployed a rails 4 application in OpsWorks (Ubuntu 14.04, nginx and unicorn), when I open the homepage I'm getting a 502 Bad Gateway error. In nginx/error.log I can see this error:
2015/01/25 06:19:42 [error] 3652#0: *1 connect() to unix:/srv/www/app/shared/sockets/unicorn.sock failed (111: Connection refused) while connecting to upstream, client: IP, server: app$
For more information here you can see my nginx.conf:
user www-data; worker_processes 10; error_log /var/log/nginx/error.log; pid /run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; access_log /var/log/nginx/access.log; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; gzip on; gzip_static on; gzip_http_version 1.0; gzip_comp_level 2; gzip_proxied any; gzip_types application/x-javascript application/xhtml+xml application/xml application/xml+rss text/css text/javascript text/plain text/xml; gzip_vary on; gzip_disable "MSIE [1-6].(?!.*SV1)"; client_max_body_size 4m; server_names_hash_bucket_size 64; include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; upstream unicorn-app { server unix:/srv/www/app/shared/sockets/unicorn.sock fail_timeout=0; } }
Updated:
I have added 777 permission for the shared and sockets folder, and also for the unicorn.sock as you can see here:
drwxrwxrwx 9 deploy www-data 4096 Jan 25 06:01 shared
drwxrwxrwx 2 deploy www-data 4096 Jan 25 05:12 sockets
-rwxrwxrwx 1 deploy www-data 0 Jan 25 05:12 unicorn.sock
But I still have the same problem:
2015/01/26 21:19:52 [error] 3652#0: *62 connect() to unix:/srv/www/app/shared/sockets/unicorn.sock failed (111: Connection refused) while connecting to upstream, client: IP, server: app, request: "GET / HTTP/1.1", upstream: "http://unix:/srv/www/app/shared/sockets/unicorn.sock:/", host: "ec2-117.us-west-2.compute.amazonaws.com"
-
AD7six over 9 yearsunicorn is not running, or the path to the socket is wrong.
-
darkcode over 9 yearsif I write ps aux | grep unicorn,here is the result: ubuntu 16092 0.0 0.0 10464 932 pts/0 S+ 17:29 0:00 grep --color=auto unicorn
-
AD7six over 9 yearsthat eliminates one cause - how about the other?
-
darkcode over 9 yearswhen I try to enter in the /srv/www/app/shared folder I get "Permission denied" error, I can change the permissions for this folder, but would be good? The shared folder would be a correct location for the unicorn.sock?
-
readyornot about 8 years@darkcode, did you ever get this resolved? I am struggling with the exact same issue. Thanks!
-
-
darkcode over 9 yearsthe permission for the ww-data looks like correctly as you can see in the last update