Why do I get 'Connection refused - connect(2)' for some models?
Posted
by Will
on Stack Overflow
See other posts from Stack Overflow
or by Will
Published on 2010-06-15T23:00:02Z
Indexed on
2010/06/16
19:52 UTC
Read the original article
Hit count: 131
mysql
|ruby-on-rails
I have a rails application running for the past 90 days that suddenly stopped working.
Debugging the problem I found that I can read from the DB but not write to it. At least for certain models.
There is one model that I can save whereas all others return Connection refused - connect(2)
when I attempt to save them.
They all used to work fine last month. I have no idea how to determine what the problem may be.
Unfortunately I do not have access to the actual server remotely right now so I am limited in my debugging ability.
I was able to get some non-tech people to run simple commands though that may help identify my problem. I will also be getting access tomorrow at some point.
1 Check from the console
./script/console
>> a = Post.last.clone
=> #<Post id: nil, title: "test"...
>> a.ex_id = 7
>> a.save
Connection refused - connect(2)
...
...
>> b = Story.last.console
=> #<Story id: nil, title: "test"...
>> a.ex_id = 7
>> a.save
=> true
I am not sure why this works for story
and not post
. This is consistent over many tests.
2 Check from mysql
./script/dbconsole -p
mysql> INSERT INTO Posts (`title`,`body`, `ex_id`) SELECT `title`, `body`, 7 FROM Posts WHERE ID = 1;
Query OK, 1 row affected (0.01 sec)
Records: 1 Duplicates: 0 Warnings: 0
And as you can see I am able to write to the table with the same credientials that Rails uses?
Does anyone know why I get connection refused in the console?
© Stack Overflow or respective owner