Adaptive Server connection timed out

April 11, 2018
mssql tiny_tds ruby

If you are getting this error when trying to connect to a mssql database from tiny_tds, the first and most important step is the following:

Configure the firewall to allow SQL Server access!

I just spent a full day trying to solve this problem even though I have been working with mssql and ruby for more than ten years.


It is also useful to test if SQL Server is accepting TCP connections from the same machine using a Microsoft Data Link as explained as explained here


The following ruby script, explained here is also useful to test the connection

require 'tiny_tds'
@client = TinyTds::Client.new username: 'sa', password: 'your_password', host: 'localhost', port: 1433
puts 'Connecting to SQL Server'

if @client.active? == true then puts 'Done' end

@client.close