# Ruby/mysql connection close problem

**URL:** <https://www.ruby-forum.com/t/ruby-mysql-connection-close-problem/151371>\
**Category:** Ruby\
**Created:** [October 20, 2008, 8:07pm UTC](https://www.ruby-forum.com/t/ruby-mysql-connection-close-problem/151371 "2008-10-20T20:07:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![omgitsads](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/dbc845/32.png) [@omgitsads](https://www.ruby-forum.com/u/omgitsads)\
**Post date:** [October 20, 2008, 8:07pm UTC](https://www.ruby-forum.com/t/ruby-mysql-connection-close-problem/151371/1 "2008-10-20T20:07:16Z")

</div>

Hello,

I am using the Ruby/mysql module installed from gems and everything is  
working fine except the connections arent closing. I was under the  
impression that upon completion of a script the database handle will  
close automatically but regardless even by explicitly stating  
dbh.close() at the end of the script I cant get the database to close  
the connection. This is obviously a problem as the limit of connections  
is eventually reached.

I am running apache2 on ubuntu 7.10, I am calling the ruby script (that  
connects and queries the database) from embedded ruby in an .rhtml file.

I do not have the code available right now as I am posting from another  
computer but can post the code if anyone thinks it will help.

Any help appreciated,

Thanks

---

<div class="post-metadata">

**Author:** ![omgitsads](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/dbc845/32.png) [@omgitsads](https://www.ruby-forum.com/u/omgitsads)\
**Post date:** [October 21, 2008, 5:23am UTC](https://www.ruby-forum.com/t/ruby-mysql-connection-close-problem/151371/2 "2008-10-21T05:23:49Z")

</div>

> I am running apache2 on ubuntu 7.10, I am calling the ruby script (that  
> connects and queries the database) from embedded ruby in an .rhtml file.
> 
> I do not have the code available right now as I am posting from another  
> computer but can post the code if anyone thinks it will help.
> 
> Any help appreciated,
> 
> Thanks

I suppose if you got really desperate you could use mysqlplus then hard  
force close the connection.

descriptor\_number = conn.socket  
a = IO.new(descriptor\_number)  
a.close  
Maybe.  
-=R
