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

227 views
Skip to first unread message

Jaimin Pandya

unread,
Jun 20, 2014, 5:29:01 AM6/20/14
to rubyonra...@googlegroups.com
I am reading " Agile Web Developement with rails". I am using Ruby 1.9.3
and Rails 3.2.16.


I can able to run application locally But application not working on
heroku. I deployed my application successfully on heroku.

When I run rake test, there is no failure.

When I click on place order button i got error like:

>We're sorry, but something went wrong.

I have attached heroku logs and order_controller.rb file. Please find
it.

How can i solve this error?

Kind regards

Attachments:
http://www.ruby-forum.com/attachment/9823/orders_controller.rb


--
Posted via http://www.ruby-forum.com/.

Colin Law

unread,
Jun 20, 2014, 6:30:45 AM6/20/14
to rubyonra...@googlegroups.com
On 20 June 2014 10:28, Jaimin Pandya <li...@ruby-forum.com> wrote:
> I am reading " Agile Web Developement with rails". I am using Ruby 1.9.3
> and Rails 3.2.16.
>
>
> I can able to run application locally But application not working on
> heroku. I deployed my application successfully on heroku.
>
> When I run rake test, there is no failure.
>
> When I click on place order button i got error like:
>
>>We're sorry, but something went wrong.
>
> I have attached heroku logs and order_controller.rb file. Please find
> it.

You do not seem to have attached the log, but rather than attach the
whole thing just copy/paste the relevant lines leading up to the
error. You do know that you must use postgres for heroku I hope. If
it is not that then also post database.yml.

Colin

Jaimin Pandya

unread,
Jun 20, 2014, 8:13:07 AM6/20/14
to rubyonra...@googlegroups.com
> You do not seem to have attached the log, but rather than attach the
> whole thing just copy/paste the relevant lines leading up to the
> error. You do know that you must use postgres for heroku I hope. If
> it is not that then also post database.yml.
>

I have attached Gemfile, database.yml and heroku logs.doc file. Please
find it.

>> Please avoid heroku_logs.odt file, if it is not open.

Kind regards

Colin Law

unread,
Jun 20, 2014, 8:38:09 AM6/20/14
to rubyonra...@googlegroups.com
On 20 June 2014 13:12, Jaimin Pandya <li...@ruby-forum.com> wrote:
>> You do not seem to have attached the log, but rather than attach the
>> whole thing just copy/paste the relevant lines leading up to the
>> error. You do know that you must use postgres for heroku I hope. If
>> it is not that then also post database.yml.
>>
>
> I have attached Gemfile, database.yml and heroku logs.doc file. Please
> find it.

No you haven't, at least I cannot see them. Please read my previous
message, just copy/paste the relevant lines of the log. Also
copy/paste database.yml. Gemfile is not required (at least not yet).
Also please confirm that you understand that you must use postgres.

Colin

Jaimin Pandya

unread,
Jun 20, 2014, 9:26:47 AM6/20/14
to rubyonra...@googlegroups.com
>> I have attached Gemfile, database.yml and heroku logs.doc file. Please
>> find it.
>
> No you haven't, at least I cannot see them. Please read my previous
> message, just copy/paste the relevant lines of the log. Also
> copy/paste database.yml. Gemfile is not required (at least not yet).
> Also please confirm that you understand that you must use postgres.



I have copy/paste the relevant lines of the log and database.yml.

Kind regards.

Jaimin Pandya

unread,
Jun 20, 2014, 9:27:02 AM6/20/14
to rubyonra...@googlegroups.com
Colin Law wrote in post #1150300:
>
> No you haven't, at least I cannot see them. Please read my previous
> message, just copy/paste the relevant lines of the log. Also
> copy/paste database.yml. Gemfile is not required (at least not yet).
> Also please confirm that you understand that you must use postgres.
>

I have copy/paste the relevant lines of the log and database.yml.

Kind regards.

Colin Law

unread,
Jun 20, 2014, 10:41:54 AM6/20/14
to rubyonra...@googlegroups.com
On 20 June 2014 14:26, Jaimin Pandya <li...@ruby-forum.com> wrote:
>>> I have attached Gemfile, database.yml and heroku logs.doc file. Please
>>> find it.
>>
>> No you haven't, at least I cannot see them. Please read my previous
>> message, just copy/paste the relevant lines of the log. Also
>> copy/paste database.yml. Gemfile is not required (at least not yet).
>> Also please confirm that you understand that you must use postgres.
>
>
>
> I have copy/paste the relevant lines of the log and database.yml.

Well I still don't see them. When I say copy/paste I mean to copy the
text out of the log or file and paste it into the message before you
send it. So you should be able to see the text in the message.

Also you *still* have not confirmed that you understand that you must
use postgres.

Colin

Jaimin Pandya

unread,
Jun 20, 2014, 11:59:43 AM6/20/14
to rubyonra...@googlegroups.com
Colin Law wrote in post #1150316:
>Output of Heroku logs:

2014-06-20T15:56:59.194349+00:00 app[web.1]:Rendered
line_items/_line_item.text.erb (3.6ms)

2014-06-20T15:56:59.206754+00:00 app[web.1]: Sent mail to
cust...@pragmatic.com (10.4ms)

2014-06-20T15:56:59.206917+00:00 app[web.1]: Completed 500 Internal
Server Error in 61.0ms

2014-06-20T15:56:59.194386+00:00 app[web.1]: Rendered
order_notifier/received.text.erb (4.8ms)

2014-06-20T15:56:59.206750+00:00 app[web.1]:
2014-06-20T15:56:59.208468+00:00 app[web.1]:
2014-06-20T15:56:59.208476+00:00 app[web.1]:

2014-06-20T15:56:59.208471+00:00 app[web.1]: Errno::ECONNREFUSED
(Connection refused - connect(2)):

2014-06-20T15:56:59.208474+00:00 app[web.1]:
app/controllers/orders_controller.rb:56:in `block in create'

2014-06-20T15:56:59.208475+00:00 app[web.1]:
app/controllers/orders_controller.rb:52:in `create'


>Code of database.yml as follow:

# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000

production:
adapter: sqlite3
database: db/production.sqlite3
pool: 5
timeout: 5000

I have used postgres gem in Gemfile which is require to deploy
application to Heroku.

Kind regards,

Scott Ribe

unread,
Jun 20, 2014, 12:03:26 PM6/20/14
to rubyonra...@googlegroups.com
On Jun 20, 2014, at 9:58 AM, Jaimin Pandya <li...@ruby-forum.com> wrote:

> I have used postgres gem in Gemfile which is require to deploy
> application to Heroku.

Yet you have specified sqlite as the database adapter.

--
Scott Ribe
scott...@elevated-dev.com
http://www.elevated-dev.com/
(303) 722-0567 voice




Jaimin Pandya

unread,
Jun 20, 2014, 12:18:15 PM6/20/14
to rubyonra...@googlegroups.com
> On Jun 20, 2014, at 9:58 AM, Jaimin Pandya <li...@ruby-forum.com> wrote:

> Yet you have specified sqlite as the database adapter.

Means I should use postgres as the database adapter in development. Is
it correct?

Colin Law

unread,
Jun 20, 2014, 12:22:12 PM6/20/14
to rubyonra...@googlegroups.com
On 20 June 2014 17:17, Jaimin Pandya <li...@ruby-forum.com> wrote:
>> On Jun 20, 2014, at 9:58 AM, Jaimin Pandya <li...@ruby-forum.com> wrote:
>
>> Yet you have specified sqlite as the database adapter.
>
> Means I should use postgres as the database adapter in development. Is
> it correct?

I presume you have worked through Heroku's guide [1]? If not then do
so. Also work right through a good tutorial such as
railstutorial.org, which is free to use online, and includes setup on
Heroku I believe.

[1] https://devcenter.heroku.com/articles/getting-started-with-rails4

Colin

>
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/0b008a3e1275871afd2f123f973eeb1a%40ruby-forum.com.
> For more options, visit https://groups.google.com/d/optout.

Jason Fleetwood-Boldt

unread,
Jun 20, 2014, 12:31:50 PM6/20/14
to rubyonra...@googlegroups.com


You may wish to note that depending if you have Rails 4.0 or 4.1 your database.yml file may or may not be overwritten by the heroku deploy



Jaimin -- what's on line app/controllers/orders_controller.rb:56 in your app ? 

Whatever apperas on that link created a heroku error Errno::ECONNREFUSED 
(Connection refused - connect(2))


(typically that kind of error happens when the rails app is unable to connect to an external service -- like a database or redis, however, as you can see the exact service is unspecified in this log file example)

Since your issue appears to be a connectivity problem with the Heroku grid, I suggest you take it up with a support ticket with Heroku directly. 


Typcially for my Heroku deploys I put the config/database.yml file in my .gitignore so it does not appear in the repository, and let Heroku write it directly since that mechanism is sure to write out what ever database you have set in your heroku config variables. 

Finally, I would echo what cla...@gmail.com said in that Postgres is the default (and preferred) for Heroku. (Although he is incorrect that you "must use Postgres" -- there are a number of alternative databases that can be found in the Heroku add-ons page.)

-Jason
-- 
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.

Jaimin Pandya

unread,
Jun 20, 2014, 12:32:41 PM6/20/14
to rubyonra...@googlegroups.com
On 20 June 2014 17:17, Jaimin Pandya <li...@ruby-forum.com> wrote:

> I presume you have worked through Heroku's guide [1]? If not then do
> so. Also work right through a good tutorial such as
> railstutorial.org, which is free to use online, and includes setup on
> Heroku I believe.
>
> [1] https://devcenter.heroku.com/articles/getting-started-with-rails4

Thank you for your advise.I will read good tutorial link.

I have **sqlite** gem in development group and **pg** gem in production
group.

Could I use in this way?

Kind regards

Walter Lee Davis

unread,
Jun 20, 2014, 1:04:12 PM6/20/14
to rubyonra...@googlegroups.com
Yes, but that's not enough. As Colin pointed out, you still are using the sqlite3 adapter in your database.yml file. You have to change that to pg as well, the gems and config have to match.

Walter

>
> Kind regards
>
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/8d2cf141f63dc24db6d4365c81dcf818%40ruby-forum.com.

Colin Law

unread,
Jun 20, 2014, 5:11:23 PM6/20/14
to rubyonra...@googlegroups.com
On 20 June 2014 17:31, Jason Fleetwood-Boldt <te...@datatravels.com> wrote:
> ...
> Finally, I would echo what cla...@gmail.com said in that Postgres is the
> default (and preferred) for Heroku. (Although he is incorrect that you "must
> use Postgres" -- there are a number of alternative databases that can be
> found in the Heroku add-ons page.)

Thanks for that clarification.

Colin

Jaimin Pandya

unread,
Jun 21, 2014, 12:42:17 AM6/21/14
to rubyonra...@googlegroups.com
> https://devcenter.heroku.com/changelog-items/426
>
>
> Jaimin -- what's on line app/controllers/orders_controller.rb:56 in your
> app ?

In orders_controller.rb, line no. 56 as follow:
class OrdersController < ApplicationController
.
.
.
def create
@order = Order.new(params[:order])
@order.add_line_items_from_cart(current_cart)

respond_to do |format| **# Line no. 52**
if @order.save
Cart.destroy(session[:cart_id])
session[:cart_id] = nil
OrderNotifier.received(@order).deliver ** #line number 56 **
format.html { redirect_to store_url, notice:
'Thank you for your order.' }
format.json { render json: @order, status: :created,
location: @order }

else
@cart = current_cart
format.html { render action: "new" }
format.json { render json: @order.errors,
status: :unprocessable_entity }
end
end
end
.
.
.
end

Matt Jones

unread,
Jun 22, 2014, 11:34:16 PM6/22/14
to rubyonra...@googlegroups.com


On Friday, 20 June 2014 23:42:17 UTC-5, Ruby-Forum.com User wrote:
> https://devcenter.heroku.com/changelog-items/426
>
>
> Jaimin -- what's on line app/controllers/orders_controller.rb:56 in your
> app ?

In orders_controller.rb, line no. 56 as follow:
class OrdersController < ApplicationController
.
.
.
 def create
    @order = Order.new(params[:order])
    @order.add_line_items_from_cart(current_cart)

    respond_to do |format|    **# Line no. 52**
      if @order.save
        Cart.destroy(session[:cart_id])
        session[:cart_id] = nil
        OrderNotifier.received(@order).deliver    ** #line number 56 **


I suspect this is the email delivery blowing up - note that you'll need to configure an email service on Heroku.

--Matt Jones 

Jaimin Pandya

unread,
Jun 23, 2014, 3:36:43 AM6/23/14
to rubyonra...@googlegroups.com
Could I do it by using addons?

Kind regards
Reply all
Reply to author
Forward
0 new messages