title: Rails application deployed on Elastic Beanstalk with Puma fails - 502 Bad Gateway
body: <p>when i was deploying new version I ran to this error.  I tried to follow couple instruction on stack-overflow but was no help. when i deploy, The Health status comes as succeed at first then when i visit the website it changes to Degraded. 
  On the website I Get the error
   <br/> <br/>502 Bad Gateway
    <br/>nginx/1.12.1</p>
  
  <p>here is image from nginx/error.log
  <a href="https://i.stack.imgur.com/3FUrC.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3FUrC.jpg" alt="enter image description here"></a></p>
  
  <p>error</p>
  
  <pre><code>2018/07/22 23:11:55 [error] 3038#0: *5502 connect() to unix:///var/run/puma/my_app.sock failed (111: Connection refused) while connecting to upstream, client: 68.228.233.169, server: _, request: "GET /robots.txt HTTP/1.1", upstream: "http://unix:///var/run/puma/my_app.sock:/robots.txt", host: "borroupenv.us-east-1.elasticbeanstalk.com"
  2018/07/22 23:11:55 [error] 3038#0: *5498 connect() to unix:///var/run/puma/my_app.sock failed (111: Connection refused) while connecting to upstream, client: 68.228.233.169, server: _, request: "GET /favicon.ico HTTP/1.1", upstream: "http://unix:///var/run/puma/my_app.sock:/favicon.ico", host: "borroupenv.us-east-1.elasticbeanstalk.com", referrer: "http://borroupenv.us-east-1.elasticbeanstalk.com/"
  </code></pre>
  
  <p>this is from puma.rb</p>
  
  <pre><code> threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
   threads threads_count, threads_count
   port        ENV.fetch("PORT") { 3000 }
   environment ENV.fetch("RAILS_ENV") { "development" }
   bind "unix:///var/run/puma/my_app.sock"
   pidfile "/var/run/puma/my_app.sock"
   plugin :tmp_restart
  </code></pre>
  
  <p>this is from config/environments/production.rb</p>
  
  <pre><code>Rails.application.configure do
    config.cache_classes = true
    config.eager_load = true
    config.consider_all_requests_local       = false
    config.action_controller.perform_caching = true
    config.read_encrypted_secrets = true
    config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
    config.assets.js_compressor = :uglifier
    config.assets.compile = false
    config.log_level = :debug
    config.log_tags = [ :request_id ]
    config.action_mailer.perform_caching = false
    config.action_mailer.delivery_method = :smtp
    config.action_mailer.smtp_settings = {
       address: 'smtp.mailgun.org',
       port: 587,
       domain: 'borroup.com',
       enable_starttls_auto: true,
       authentication: 'plain',
       user_name: '',
       password: ''
     } 
     config.i18n.fallbacks = true
     config.active_support.deprecation = :notify
     config.log_formatter = ::Logger::Formatter.new
       if ENV["RAILS_LOG_TO_STDOUT"].present?
       logger           = 
        ActiveSupport::Logger.new(STDOUT)
       logger.formatter = config.log_formatter
       config.logger    = 
       ActiveSupport::TaggedLogging.new(logger)
       end
    config.active_record.dump_schema_after_migration = 
   false
  end
  </code></pre>