9

我能够预编译资产以推送到 Enki 博客的 Heroku,我成功迁移了数据库。但是当我尝试运行时,我heroku open在 Heroku 上得到了错误消息页面(该应用程序在本地运行)。然后我跑了heroku logs,看到了这个错误

Errno::ECONNREFUSED (Connection refused - connect(2)):

谁能解释可能是什么问题?

Processing by HomesController#index as HTML
2012-07-12T06:14:38+00:00 app[web.1]:   Rendered homes/index.html.erb within layouts/application (2.1ms)
2012-07-12T06:14:38+00:00 app[web.1]: Completed 500 Internal Server Error in 7ms
2012-07-12T06:14:38+00:00 app[web.1]:   Rendered vendor/bundle/ruby/1.9.1/gems/exception_notification-2.5.2/lib/exception_notifier/views/exception_notifier/_request.text.erb (0.2ms)
2012-07-12T06:14:38+00:00 app[web.1]:   Rendered vendor/bundle/ruby/1.9.1/gems/exception_notification-2.5.2/lib/exception_notifier/views/exception_notifier/_title.text.erb (0.1ms)
2012-07-12T06:14:38+00:00 app[web.1]:   Rendered vendor/bundle/ruby/1.9.1/gems/exception_notification-2.5.2/lib/exception_notifier/views/exception_notifier/_session.text.erb (0.3ms)
2012-07-12T06:14:38+00:00 app[web.1]:   Rendered vendor/bundle/ruby/1.9.1/gems/exception_notification-2.5.2/lib/exception_notifier/views/exception_notifier/_title.text.erb (0.0ms)
2012-07-12T06:14:38+00:00 app[web.1]:   Rendered vendor/bundle/ruby/1.9.1/gems/exception_notification-2.5.2/lib/exception_notifier/views/exception_notifier/_environment.text.erb (13.9ms)
2012-07-12T06:14:38+00:00 app[web.1]:   Rendered vendor/bundle/ruby/1.9.1/gems/exception_notification-2.5.2/lib/exception_notifier/views/exception_notifier/_title.text.erb (0.0ms)
2012-07-12T06:14:38+00:00 app[web.1]:   Rendered vendor/bundle/ruby/1.9.1/gems/exception_notification-2.5.2/lib/exception_notifier/views/exception_notifier/_backtrace.text.erb (0.1ms)
2012-07-12T06:14:38+00:00 app[web.1]:   Rendered vendor/bundle/ruby/1.9.1/gems/exception_notification-2.5.2/lib/exception_notifier/views/exception_notifier/_title.text.erb (0.1ms)
2012-07-12T06:14:38+00:00 app[web.1]:   Rendered vendor/bundle/ruby/1.9.1/gems/exception_notification-2.5.2/lib/exception_notifier/views/exception_notifier/exception_notification.text.erb (18.4ms)
2012-07-12T06:14:41+00:00 app[web.1]:   vendor/ruby-1.9.3/lib/ruby/1.9.1/net/smtp.rb:540:in `initialize'
2012-07-12T06:14:41+00:00 app[web.1]: 
2012-07-12T06:14:41+00:00 app[web.1]: Errno::ECONNREFUSED (Connection refused - connect(2)):
2012-07-12T06:14:41+00:00 app[web.1]:   vendor/ruby-1.9.3/lib/ruby/1.9.1/net/smtp.rb:540:in `open'
2012-07-12T06:14:41+00:00 app[web.1]:   vendor/ruby-1.9.3/lib/ruby/1.9.1/net/smtp.rb:540:in `tcp_socket'
2012-07-12T06:14:41+00:00 app[web.1]:   vendor/ruby-1.9.3/lib/ruby/1.9.1/net/smtp.rb:549:in `block in do_start'
2012-07-12T06:14:41+00:00 app[web.1]:   vendor/ruby-1.9.3/lib/ruby/1.9.1/timeout.rb:68:in `timeout'
2012-07-12T06:14:41+00:00 app[web.1]:   vendor/ruby-1.9.3/lib/ruby/1.9.1/net/smtp.rb:519:in `start'
2012-07-12T06:14:41+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/mail-2.4.4/lib/mail/message.rb:2034:in `do_delivery'
2012-07-12T06:14:41+00:00 app[web.1]:   vendor/ruby-1.9.3/lib/ruby/1.9.1/timeout.rb:99:in `timeout'
2012-07-12T06:14:41+00:00 app[web.1]:   vendor/ruby-1.9.3/lib/ruby/1.9.1/net/smtp.rb:549:in `do_start'

更新

它试图发送一封电子邮件,因为通知我另一个错误。一旦我关闭了电子邮件,它就给了我这个错误消息。我找不到未定义的方法/Nil Class 将是它所指的。

Started GET "/" for 24.84.41.17 at 2012-07-12 17:44:12 +0000
2012-07-12T17:44:12+00:00 app[web.1]: Processing by HomesController#index as HTML
2012-07-12T17:44:12+00:00 app[web.1]:   Rendered homes/index.html.erb within layouts/application (1.2ms)
2012-07-12T17:44:12+00:00 app[web.1]: Completed 500 Internal Server Error in 99ms
2012-07-12T17:44:12+00:00 app[web.1]: 
2012-07-12T17:44:12+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/mail-2.4.4/lib/mail/fields/common/common_address.rb:20:in `encode_if_needed'
2012-07-12T17:44:12+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/mail-2.4.4/lib/mail/field.rb:169:in `new_field'
2012-07-12T17:44:12+00:00 app[web.1]: NoMethodError (undefined method `ascii_only?' for nil:NilClass):
2012-07-12T17:44:12+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/mail-2.4.4/lib/mail/encodings.rb:181:in `address_encode'
2012-07-12T17:44:12+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/mail-2.4.4/lib/mail/field.rb:169:in `new'
2012-07-12T17:44:12+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/mail-2.4.4/lib/mail/field.rb:156:in `create_field'
2012-07-12T17:44:12+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/mail-2.4.4/lib/mail/encodings.rb:189:in `encode_non_usascii'
2012-07-12T17:44:12+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/mail-2.4.4/lib/mail/encodings.rb:184:in `address_encode'
2012-07-12T17:44:12+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/mail-2.4.4/lib/mail/encodings.rb:181:in `block in address_encode'
2012-07-12T17:44:12+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/mail-2.4.4/lib/mail/encodings.rb:181:in `map'
2012-07-12T17:44:12+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/mail-2.4.4/lib/mail/fields/to_field.rb:42:in `initialize'
2012-07-12T17:44:12+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/mail-2.4.4/lib/mail/fields/common/common_address.rb:9:in `parse'
2012-07-12T17:44:12+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/mail-2.4.4/lib/mail/field.rb:87:in `initialize'
4

2 回答 2

19

错误是由于您正在尝试发送电子邮件。Heroku 不提供外发邮件服务,但允许使用外部 SMTP 服务器。要启用免费的 Sendgrid 插件:$ heroku addons:add sendgrid:starter.

#Set config/environment.rb

config.action_mailer.delivery_method = :smtp

然后配置您的 SMTP 连接。

ActionMailer::Base.smtp_settings = { :address => "smtp.someserver.net", :port => 25, :user_name => "someone@someserver.net", :password => "mypass", :authentication => :login }

注意: - 免费的 Sendgrid 插件受限(每天最多发送 200 封电子邮件。)。

于 2012-07-12T09:39:06.907 回答
17

看起来您正在尝试从您的应用程序发送电子邮件 - Heroku 的平台不提供任何邮件服务。您需要使用像 SendGrid 这样的第三方(他们有 Heroku 插件)才能发送 SMTP 电子邮件。

于 2012-07-12T07:26:22.513 回答