Forum: Ruby on Rails Errno::ECONNREFUSED (Connection refused - connect(2))

1eb28f3c91b0a7b8bfb1a72cfa8befaa?d=identicon&s=25 Jaimin Pandya (jaimin)
on 2014-06-20 11:28
Attachment: orders_controller.rb (2 KB)
Attachment: heroku_logs.odt (30 KB)
Attachment: heroku_logs.doc (30 KB)
Attachment: Gemfile (908 Bytes)
Attachment: database.yml (576 Bytes)
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.

Output of Heroku logs:

    2014-06-20T09:23:11.979417+00:00 app[web.1]:
app/controllers/orders_controller.rb:52:in `create'
    2014-06-20T09:23:11.979418+00:00 app[web.1]:
    2014-06-20T09:23:11.977584+00:00 app[web.1]: Sent mail to
customer@pragmatic.com (8.8ms)
    2014-06-20T09:23:11.979414+00:00 app[web.1]: Errno::ECONNREFUSED
(Connection refused - connect(2)):
    2014-06-20T09:23:11.979416+00:00 app[web.1]:
app/controllers/orders_controller.rb:56:in `block in

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

How can i solve this error?

Kind regards
4c6bde00168d595053c09aac7e487f8e?d=identicon&s=25 Colin Law (Guest)
on 2014-06-20 12:31
(Received via mailing list)
On 20 June 2014 10:28, Jaimin Pandya <lists@ruby-forum.com> wrote:
>
>>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
1eb28f3c91b0a7b8bfb1a72cfa8befaa?d=identicon&s=25 Jaimin Pandya (jaimin)
on 2014-06-20 14:12
> 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
4c6bde00168d595053c09aac7e487f8e?d=identicon&s=25 Colin Law (Guest)
on 2014-06-20 14:38
(Received via mailing list)
On 20 June 2014 13:12, Jaimin Pandya <lists@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
1eb28f3c91b0a7b8bfb1a72cfa8befaa?d=identicon&s=25 Jaimin Pandya (jaimin)
on 2014-06-20 15:26
>> 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.
1eb28f3c91b0a7b8bfb1a72cfa8befaa?d=identicon&s=25 Jaimin Pandya (jaimin)
on 2014-06-20 15:26
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.
4c6bde00168d595053c09aac7e487f8e?d=identicon&s=25 Colin Law (Guest)
on 2014-06-20 16:42
(Received via mailing list)
On 20 June 2014 14:26, Jaimin Pandya <lists@ruby-forum.com> wrote:
> 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
1eb28f3c91b0a7b8bfb1a72cfa8befaa?d=identicon&s=25 Jaimin Pandya (jaimin)
on 2014-06-20 17:58
Colin Law wrote in post #1150316:
> On 20 June 2014 14:26, Jaimin Pandya <lists@ruby-forum.com> wrote:
>> 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.

>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
customer@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,
15eb13d662803f57bc4aea59704988b4?d=identicon&s=25 Scott Ribe (Guest)
on 2014-06-20 18:04
(Received via mailing list)
On Jun 20, 2014, at 9:58 AM, Jaimin Pandya <lists@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_ribe@elevated-dev.com
http://www.elevated-dev.com/
(303) 722-0567 voice
1eb28f3c91b0a7b8bfb1a72cfa8befaa?d=identicon&s=25 Jaimin Pandya (jaimin)
on 2014-06-20 18:17
> On Jun 20, 2014, at 9:58 AM, Jaimin Pandya <lists@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?
4c6bde00168d595053c09aac7e487f8e?d=identicon&s=25 Colin Law (Guest)
on 2014-06-20 18:23
(Received via mailing list)
On 20 June 2014 17:17, Jaimin Pandya <lists@ruby-forum.com> wrote:
>> On Jun 20, 2014, at 9:58 AM, Jaimin Pandya <lists@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-star...

Colin
1eb28f3c91b0a7b8bfb1a72cfa8befaa?d=identicon&s=25 Jaimin Pandya (jaimin)
on 2014-06-20 18:31
On 20 June 2014 17:17, Jaimin Pandya <lists@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-star...

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

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

Could I use in this way?

Kind regards
Dfc7587fd73f2efa19d6f1f9611b70ba?d=identicon&s=25 Jason Fb (jasonfb)
on 2014-06-20 18:32
(Received via mailing list)
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

https://devcenter.heroku.com/changelog-items/426


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 clanlaw@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
A47e0a6beeb9d048ff054fc1c3a97418?d=identicon&s=25 Walter Davis (walterdavis)
on 2014-06-20 19:04
(Received via mailing list)
On Jun 20, 2014, at 12:31 PM, Jaimin Pandya wrote:

>
> I have **sqlite** gem in development group and **pg** gem in production
> group.
>
> Could I use in this way?

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
4c6bde00168d595053c09aac7e487f8e?d=identicon&s=25 Colin Law (Guest)
on 2014-06-20 23:11
(Received via mailing list)
On 20 June 2014 17:31, Jason Fleetwood-Boldt <tech@datatravels.com>
wrote:
> ...
> Finally, I would echo what clanlaw@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
1eb28f3c91b0a7b8bfb1a72cfa8befaa?d=identicon&s=25 Jaimin Pandya (jaimin)
on 2014-06-21 06:41
> 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

Kind regards,
6883e5ef03484d4fcef507d7b4f1d243?d=identicon&s=25 Matt Jones (Guest)
on 2014-06-23 05:35
(Received via mailing list)
On Friday, 20 June 2014 23:42:17 UTC-5, Ruby-Forum.com User wrote:
> .
>
>
I suspect this is the email delivery blowing up - note that you'll need
to
configure an email service on Heroku.

--Matt Jones
1eb28f3c91b0a7b8bfb1a72cfa8befaa?d=identicon&s=25 Jaimin Pandya (jaimin)
on 2014-06-23 09:35
> On Friday, 20 June 2014 23:42:17 UTC-5, Ruby-Forum.com User wrote:

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

Could I do it by using addons?

Kind regards
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.