Getting occasional connect error on continuous uploads

I have a script that reads lines one by one from a csv file and index the
same to elasticsearch in the same order. My elasticsearch host is the same
machine on which the script is running. Everything else works fine except
for a few rows when I suddenly start getting the following error:

W, [2012-10-09T14:46:00.899876 #11567] WARN -- : Cannot assign requested
address - connect(2)
D, [2012-10-09T14:46:00.900037 #11567] DEBUG -- :
["/home/azitabh/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/net/http.rb:644:in
initialize'", "/home/azitabh/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/net/http.rb:644:inopen'",
"/home/azitabh/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/net/http.rb:644:in
block in connect'", "/home/azitabh/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/timeout.rb:44:intimeout'",
"/home/azitabh/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/timeout.rb:89:in
timeout'", "/home/azitabh/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/net/http.rb:644:inconnect'",
"/home/azitabh/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/net/http.rb:637:in
do_start'", "/home/azitabh/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/net/http.rb:626:instart'",
"/home/azitabh/.rvm/gems/ruby-1.9.2-p320/gems/rest-client-1.6.7/lib/restclient/request.rb:172:in
transmit'", "/home/azitabh/.rvm/gems/ruby-1.9.2-p320/gems/rest-client-1.6.7/lib/restclient/request.rb:64:inexecute'",
"/home/azitabh/.rvm/gems/ruby-1.9.2-p320/gems/tire-0.4.2/lib/tire/http/client.rb:11:in
get'", "/home/azitabh/.rvm/gems/ruby-1.9.2-p320/gems/tire-0.4.2/lib/tire/search.rb:94:inperform'",
"/home/azitabh/.rvm/gems/ruby-1.9.2-p320/gems/tire-0.4.2/lib/tire/search.rb:20:in
results'", "models/test.rb:31:inget_details'", "models/test.rb:56:in
block in index_test'", "/home/azitabh/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/csv.rb:1768:ineach'",
"/home/azitabh/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/csv.rb:1202:in
block in foreach'", "/home/azitabh/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/csv.rb:1340:inopen'",
"/home/azitabh/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/csv.rb:1201:in
foreach'", "models/test.rb:40:inindex_test'", "models/test.rb:85:in
`'"]

And the errors are not related to the values at those rows in the csv. I
get these errors at different locations at different times.

There is another error "WAIT_TIMEOUT" which I get some time. Couldn't put
the trace here as I didn't get that error this time.

I am coding in ruby and using "Tire" gem to talk to elasticsearch. I don't
feel these are responsible in any way though.

JAVA was using 8% of my system's memory at the time I got this error. This
is much below the assigned value ES_MIN_MEM=2g.

Thanks in advance
-Azitabh

--