Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to connect to a SQL instance (default instance) on a machine. When using the IP of the machine it connects to the machine. Using the name of the machine on that machine you are able to establish a connection to the SQL instance but using the machine name on another PC the connection cannot be established. And gives the error

A network-related or instance-specific error occurred while establishing a connection to SQL Server. ... (Microsoft Server, Error: 10060)

The machine that I am trying to establish the connection from can ping the machine with the SQL instance both on the IP and on the name. Why would this be and how can I fix it?

Edit: pinging the name does resolve the correct IP. Pinging the FQDN also works correctly.

share|improve this question
    
Sounds like the same problem I had a while back... that unfortunately, I had to rebuild the server to fix. Hopefully you'll have better luck finding a solution than I did. –  HopelessN00b Dec 6 '12 at 13:03

5 Answers 5

[original]The DNS name you are using to connect to the server may not be resolving to the IP hosting the instance. You can check this by using nslookup to resolve the name and verify this resolves to the instance IP address you have configured on the SQL server.

Beyond this, tas @mrdenny mentioned, there may be a network based firewall in the way, or a host based [/original]

Edit1: saw the bit about ping by name... Is the name you are pinging actually resolving to the server hosting the SQL instance?

Edit2: The named instance you have created may be configured to use a uniquely different TCP port for the listener. Your IP based listener may be on the default port, but the named instance may be listening on the next port or some other arbitrarily defined port.

Also, in SQL Configuration Manager, verify the Named Instance service is running...

share|improve this answer

It sounds like either the firewall is enabled, or SQL Server isn't configured to allow remote connections.

The firewall can be configured via the control panel. The SQL Server can be configured to support remote connections via the SQL Server Configuration Manager.

Once you have confirmed that SQL is listening on the TCP port , you can test if it's the firewall easily enough by telnetting from the client machine to the SQL port number on port 1433.

share|improve this answer
    
If this was the case, it would not be possible to connect to the machine even using its IP address. This looks like a name resolution problem, not a firewall problem at all. –  Massimo Dec 6 '12 at 13:06
    
Given that the OP said that pinging the server worked it's not DNS. The wirewall could be configured to block SQL but allow ICMP easily enough. –  mrdenny Dec 6 '12 at 16:22
    
Read it again... he said he can CONNECT TO SQL SERVER by using the IP address. So port 1433 (or any other SQL port) is definitely not blocked. –  Massimo Dec 6 '12 at 17:39
    
Did miss that part. Ping can resolve the name so DNS should be working. At this point I'd want to see what network protocol's are enabled on the SQL Server, ports, etc. that are being used when it's working and when it isn't. –  mrdenny Dec 6 '12 at 19:50

After more investigation the cause of the problem was that the machine name was added as an Alias to the IP of the correct machine but listening on port 2305 and not on 1433. Changing it to 1433 solved the problem.

share|improve this answer

Open cmd prompt and write this:

notepad C:\Windows\System32\drivers\etc\hosts

This will open the file named Hosts using Notepad.

Add one entry like below:

 [Machine_IP] [Press Tab] [Full Machine Name]

E.g. If my IP is 10.10.3.222 and FQDN of my machine is: WinServer-L2Lab.contoso.com

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
#   127.0.0.1       localhost
#   ::1             localhost
10.10.3.222      WinServer-L2Lab.contoso.com     

Save the file. And try to connect.

share|improve this answer

This looks like a name resolution problem.

You said you can ping the SQL server using its name; ok, but please double check this.

Try to ping the FQDN (servername.domain.com, not servername only) of the SQL server. Does this work? Does it actually ping the server's IP address, or does it ping a different one?

Then, try to ping the server's name without the domain suffix (thus, servername only). Does this work? Does it ping the server's IP address? Does it automatically resolve to the server's FQDN (servername.domain.com), or does it stay as you requested it (servername)?

There are a couple of possibile issues here: either the name maps to the wrong server in DNS, or DNS is not working and NetBIOS is used to resolve the name (and this could map to the wrong server, too); the above tests should clarify this. Please try them and then post your results.

share|improve this answer
    
pinged both the FQDN and the servername only same results and the IP for this ping is the same as the IP I ping and can connect to. Pinging the servername only does resolve to the FQDN. –  Cornelius Dec 6 '12 at 14:21
    
Ok, name resolution is good then. This has to be a problem specific to SQL Server. –  Massimo Dec 6 '12 at 14:39
    
Why the downvote? These were perfectly reasonable checks to do... –  Massimo Dec 6 '12 at 17:39
    
Agreed, I do think it was reasonable checks. –  Cornelius Dec 7 '12 at 8:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.