ajit123jain
ajit123jain

Reputation: 67

Cannot assign requested address - bind(2) for "xyz.herokuapp.com" port 28159 (Errno::EADDRNOTAVAIL)

I am uploading ROR application on Heroku but I am getting this error.

/app/vendor/bundle/ruby/2.4.0/gems/puma-3.12.1/lib/puma/binder.rb:273:in 'initialize':
Cannot assign requested address - bind(2) for "xyz.herokuapp.com" port 28159 (Errno::EADDRNOTAVAIL)

I attached procfile and puma.rb code.

Procfile:

web: bundle exec puma -c config/puma.rb
release: bundle exec rake db:migrate

puma.rb:

threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
threads threads_count, threads_count
port        ENV.fetch("PORT") { 3000 }
environment ENV.fetch("RAILS_ENV") { "development" }

I tried with puma 3.7 also but no luck Changed configuration of procfile too

On local its working fine but on heroku giving eror.

Upvotes: 3

Views: 813

Answers (1)

Bassirou Diaby
Bassirou Diaby

Reputation: 449

I was facing the same issue when deploying a Rails 6.0 on Heroku. I was using a environnement variable named HOST in order to provide to the ActionDispatch::HostAuthorization middleware the url of the heroku server because rails was asking for it in order to prevents against DNS rebinding and other Host header attacks. The name of the environment variable HOST was causing side effect when the heroku server was trying to start the server, the issue was discussed here and I I've used the same solution as here.

  1. heroku config:unset HOST
  2. heroku config:set DOMAIN=youdomain.com
  3. inside production.rb instead of config.hosts << ENV['HOST'] use config.hosts << ENV['DOMAIN']
  4. Add files on git, commit and deploy on heroku

Hope this will help.

Upvotes: 4

Related Questions