0

i have a problem on one of my rails app developpement. I use heroku to deploy my rails app (prod env). And i have a misunderstanding between dev and prod environnemnt.

When i excecute "require 'socket'; TCPSocket.new(nil, 80)" in my rails console in dev env (rails console, on my computer in local) and the same commande in the rails command of heroku (heroku run rails console), i don't have the same result.

In dev env, i get "#TCPSocket:fd 18" then no problem occured but in prod env i get "Errno::ECONNREFUSED: Connection refused - connect(2) for nil port 80

from (irb):1:in initialize' from (irb):1:innew'

from (irb):1

from /app/vendor/bundle/ruby/2.3.0/gems/railties 4.2.5/lib/rails/commands/console.rb:110:in `start'

from /app/vendor/bundle/ruby/2.3.0/gems/railties-4.2.5/lib/rails/commands/console.rb:9:in `start'

from /app/vendor/bundle/ruby/2.3.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:68:in `console'

from /app/vendor/bundle/ruby/2.3.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:39:in `run_command!'

from /app/vendor/bundle/ruby/2.3.0/gems/railties-4.2.5/lib/rails/commands.rb:17:in `'

from /app/bin/rails:9:in `require'

from /app/bin/rails:9:in main "

I have the same environnment (same version of ruby, rails, etc...) So, if one of you as already met the problem before or could explain me the behavior of TCPSocket in that case.

Thank you in advance.

Bozotek
  • 1
  • 2
  • I solved my problem, it was because i have already something running on my port 80 on localhost and not in prod env ! So be careful with your port ! And thanks everyone for responses. – Bozotek Mar 11 '16 at 13:26

1 Answers1

0

Does your config/production.rb mailer look like this?

 config.action_mailer.raise_delivery_errors = true
  config.action_mailer.delivery_method = :smtp
  host = 'yoursubdomain.herokuapp.com'
  config.action_mailer.default_url_options = { host: host }
  ActionMailer::Base.smtp_settings = {
    :address        => 'smtp.sendgrid.net',  //or whichever u use 
    :port           => '587',
    :authentication => :plain,
    :user_name      => ENV['SENDGRID_USERNAME'],
    :password       => ENV['SENDGRID_PASSWORD'],
    :domain         => 'heroku.com',
    :enable_starttls_auto => true
  }

end

Arminius
  • 606
  • 1
  • 6
  • 19
  • Yes but what is the relationship between my confif/production.rb and the fact that TCPSocket doesn't have the same behavior on dev and prod env ? – Bozotek Mar 11 '16 at 13:11
  • http://stackoverflow.com/questions/17141004/errnoeconnrefused-connection-refused-connect2-for-action-mailer http://stackoverflow.com/questions/23494136/connection-refused-connect2-ruby-on-rails-mail-setup – Arminius Mar 11 '16 at 22:46