# Problems connecting to remote mysql db

**URL:** <https://www.ruby-forum.com/t/problems-connecting-to-remote-mysql-db/100271>\
**Category:** Rails\
**Created:** [July 28, 2006, 2:45am UTC](https://www.ruby-forum.com/t/problems-connecting-to-remote-mysql-db/100271 "2006-07-28T02:45:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![janovetz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/53a042/32.png) [@janovetz](https://www.ruby-forum.com/u/janovetz)\
**Post date:** [July 28, 2006, 2:45am UTC](https://www.ruby-forum.com/t/problems-connecting-to-remote-mysql-db/100271/1 "2006-07-28T02:45:20Z")

</div>

Hi,

I am having a problem connecting to a remote mysql db and I can’t  
figure out what the problem is. When I try to connect I get the error:

getaddrinfo: no address associated with hostname.

I have looked all over for clues as to what that means but I haven’t  
been able to find anything that helps. I have no problems connecting  
to the database with php and with the mysql query browser, I only have  
problems connecting with rails and the settings in database.yml  
correspond to the settings I have in php. I also don’t have any  
problem connecting to the mysql db on my local machine. I have also  
tried it on Windows and Mac OSX and I get the same error on both  
platforms.

The remote db version is MySQL 4.0.15-standard. I have also granted  
privelages for the user I am connecting with for all domains.

The trace gives me:

C:/InstantRails-1.0/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active\_record/vendor/mysql.rb:108:in  
`initialize' C:/InstantRails-1.0/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/vendor/mysql.rb:108:in`real\_connect’  
C:/InstantRails-1.0/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active\_record/connection\_adapters/mysql\_adapter.rb:330:in  
`connect' C:/InstantRails-1.0/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/connection_adapters/mysql_adapter.rb:87:in`initialize’  
C:/InstantRails-1.0/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active\_record/connection\_adapters/mysql\_adapter.rb:36:in  
`mysql_connection' C:/InstantRails-1.0/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:251:in`connection\_without\_query\_cache=’  
C:/InstantRails-1.0/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active\_record/query\_cache.rb:54:in  
`connection=' C:/InstantRails-1.0/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:220:in`retrieve\_connection’  
C:/InstantRails-1.0/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active\_record/connection\_adapters/abstract/connection\_specification.rb:78:in  
`connection' C:/InstantRails-1.0/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/base.rb:1046:in`add\_limit!’  
C:/InstantRails-1.0/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active\_record/base.rb:1017:in  
`construct_finder_sql' C:/InstantRails-1.0/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/base.rb:924:in`find\_every’  
C:/InstantRails-1.0/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active\_record/base.rb:381:in  
`find' #{RAILS_ROOT}/app/controllers/intro_controller.rb:24:in`auth’

If anyone has an idea about what is going on I would really appreciate  
it.

Thanks,  
Jake

---

<div class="post-metadata">

**Author:** ![janovetz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/53a042/32.png) [@janovetz](https://www.ruby-forum.com/u/janovetz)\
**Post date:** [July 28, 2006, 3:19am UTC](https://www.ruby-forum.com/t/problems-connecting-to-remote-mysql-db/100271/2 "2006-07-28T03:19:17Z")

</div>

On Thu, 2006-07-27 at 17:42 -0700, Jake J. wrote:

> problems connecting with rails and the settings in database.yml  
> correspond to the settings I have in php. I also don’t have any  
> problem connecting to the mysql db on my local machine. I have also  
> tried it on Windows and Mac OSX and I get the same error on both  
> platforms.
> 
> The remote db version is MySQL 4.0.15-standard. I have also granted  
> privelages for the user I am connecting with for all domains.
> 
> The trace gives me:

* * *

make sure that there are no tab characters in database.yml, only spaces  
as separators.

gettaddinfo: no address associated with hostname means that the ‘host’  
name listed within database.yml so it would seem that the problem is  
either a typo or use of tabs instead of spaces

Craig

---

<div class="post-metadata">

**Author:** ![janovetz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/53a042/32.png) [@janovetz](https://www.ruby-forum.com/u/janovetz)\
**Post date:** [July 28, 2006, 4:18am UTC](https://www.ruby-forum.com/t/problems-connecting-to-remote-mysql-db/100271/3 "2006-07-28T04:18:33Z")

</div>

Craig,

Thank you very much. I didn’t have any tab characters in my  
database.yml file (although I didn’t know that and it is a useful  
thing to know) but that led me to the right answer. The problem was  
that I had the port number as part of the host with the host.

I had the host set like I did in php

host: [my.domain.com:3306](http://my.domain.com:3306)

and I found an example of the correct way

host: [my.domain.com](http://my.domain.com)  
port: 3306

Thanks again,  
Jake
