I just deployed a Rails app to Elastic Beanstalk, and every request is giving me a 502 error.
Here's the contents of /var/logs/nginx/error.log
2015/05/20 16:24:25 [warn] 1535#0: conflicting server name "localhost" on 0.0.0.0:80, ignored
2015/05/20 16:27:12 [crit] 1537#0: *20 connect() to unix:///var/run/puma/my_app.sock failed (2: No such file or directory) while connecting to upstream, client: 172.31.51.94, server: _, request: "POST /get HTTP/1.1", upstream: "http://unix:///var/run/puma/my_app.sock:/get", host: "securities-api-prod.elasticbeanstalk.com"
2015/05/20 16:27:17 [crit] 1537#0: *20 connect() to unix:///var/run/puma/my_app.sock failed (2: No such file or directory) while connecting to upstream, client: 172.31.51.94, server: _, request: "POST /get HTTP/1.1", upstream: "http://unix:///var/run/puma/my_app.sock:/get", host: "securities-api-prod.elasticbeanstalk.com"
2015/05/20 16:27:19 [crit] 1537#0: *20 connect() to unix:///var/run/puma/my_app.sock failed (2: No such file or directory) while connecting to upstream, client: 172.31.51.94, server: _, request: "POST /get HTTP/1.1", upstream: "http://unix:///var/run/puma/my_app.sock:/get", host: "securities-api-prod.elasticbeanstalk.com"
2015/05/20 16:27:22 [crit] 1537#0: *16 connect() to unix:///var/run/puma/my_app.sock failed (2: No such file or directory) while connecting to upstream, client: 172.31.44.210, server: _, request: "GET /datapoint?tickers=AAPL&datapoints=Ratings HTTP/1.1", upstream: "http://unix:///var/run/puma/my_app.sock:/datapoint?tickers=AAPL&datapoints=Ratings", host: "securities-api-prod.elasticbeanstalk.com"
2015/05/20 16:27:27 [crit] 1537#0: *20 connect() to unix:///var/run/puma/my_app.sock failed (2: No such file or directory) while connecting to upstream, client: 172.31.51.94, server: _, request: "POST /get HTTP/1.1", upstream: "http://unix:///var/run/puma/my_app.sock:/get", host: "securities-api-prod.elasticbeanstalk.com"
2015/05/20 16:27:32 [crit] 1537#0: *20 connect() to unix:///var/run/puma/my_app.sock failed (2: No such file or directory) while connecting to upstream, client: 172.31.51.94, server: _, request: "POST /get HTTP/1.1", upstream: "http://unix:///var/run/puma/my_app.sock:/get", host: "securities-api-prod.elasticbeanstalk.com"
2015/05/20 16:28:53 [crit] 1537#0: *52 connect() to unix:///var/run/puma/my_app.sock failed (2: No such file or directory) while connecting to upstream, client: 172.31.51.94, server: _, request: "GET /datapoint?tickers=AAPL&datapoints=Ratings HTTP/1.1", upstream: "http://unix:///var/run/puma/my_app.sock:/datapoint?tickers=AAPL&datapoints=Ratings", host: "securities-api-prod.elasticbeanstalk.com"
2015/05/20 16:30:47 [crit] 1537#0: *69 connect() to unix:///var/run/puma/my_app.sock failed (2: No such file or directory) while connecting to upstream, client: 172.31.51.94, server: _, request: "POST /get HTTP/1.1", upstream: "http://unix:///var/run/puma/my_app.sock:/get", host: "securities-api-prod.elasticbeanstalk.com"
I think puma is running -
[ec2-user@ip-172-31-44-135 nginx]$ ps aux | grep puma
root 23299 1.0 0.2 53008 1428 ? Ss 16:38 0:00 su -s /bin/bash -c puma -C /opt/elasticbeanstalk/support/conf/pumaconf.rb webapp
webapp 23314 0.0 2.4 75764 14604 ? Rsl 16:38 0:00 /opt/rubies/ruby-2.1.4/bin/ruby /opt/rubies/ruby-2.1.4/bin/puma -C /opt/elasticbeanstalk/support/conf/pumaconf.rb
ec2-user 23317 0.0 0.1 110284 844 pts/0 S+ 16:38 0:00 grep puma
pumaconf.rb
directory '/var/app/current'
threads 8, 32
workers %x(grep -c processor /proc/cpuinfo)
bind 'unix:///var/run/puma/my_app.sock'
stdout_redirect '/var/log/puma/puma.log', '/var/log/puma/puma.log', true
daemonize false
Anyone know what's going on?
I faced the same error and adding these two lines to config/puma.rb
fixed the problem:
bind "unix:///var/run/puma/my_app.sock"
pidfile "/var/run/puma/my_app.sock"
After this step I faced another error to add ENV values, which is very straight forward.
Hope this helps.
Sorry - Super late to the game. But I found this entry when searching for the same error message and could solve it differently.
I am trying to let a Rails 6.1.1 (currently latest and greatest) application run on AWS Beanstalk (Puma with Ruby 2.6), where I got the same error as described in this post: Nginx throwing above connection error / Puma seems not reactive (no entries in puma logs) / When SSHing into the machine it shows Puma is running (initctl status puma
-> shows process ID).
After some days of research (and trying all above answers without success) - I switched to Passenger - but still same result. Researching the same problem for Passenger showed the proper solution:
Do not use the gem of the application server in production when you want to use the already provided application server of the AWS platform branch ("Puma with Ruby 2.6..." or "Passenger with Ruby 2.6...") (it somehow collides with the already installed version). Therefore in your Gemfile:
gem 'puma', '~> 5.0', groups: [:development, :test]
respectively:
gem "passenger", ">= 5.3.2", require: "phusion_passenger/rack_handler", groups: [:development, :test]
or use the AWS Beanstalk platform without already installed application server ("Ruby 2.6 running on...)
PS: Seems to be only a solution for higher Rails versions (my old Rails 5.1 app runs perfectly on the "Puma with Ruby 2.6" platform even with the gem "normally" installed.
In my case, this was happening because of a Gem loading error. I was able to reproduce the error by connecting to the server with eb ssh
and running pumactl start
.
For me, the conflict was with the nio4r
gem, although for others it was the puma
gem. Setting it to the same version as the Elastic Beanstalk platform's gem fixed the error.
More details here: https://stackoverflow.com/a/67110462/1852005 and here: https://forums.aws.amazon.com/thread.jspa?messageID=957426
Changing config.force_ssl = true
to false
fixed the issue for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With