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.

EDIT

New info: Navigating to localhost:1434 in Chrome gives me an "ERR_EMPTY_RESPONSE", while other ports give me an "Oops! This link appears to be broken". So it seems to binding ok there?

So here's my setup so far:

  • I've configured Windows Firewall to allow TCP on 1433 and UDP on 1434.
  • I've set up SQL Server to use any IP on Port 1433 (using the SQL Server Configuration Manager).
  • My hosts file contains the default entries ("127.0.0.1 localhost" and "::1 localhost").
  • I sometimes have a debug session of Visual Web Developer running a webserver, but it's on a specific port (localhost:5XXXX).

What I've tried:

  • I CAN ping localhost in a cmd prompt.
  • I CAN connect to the database through SSMS if I specify 127.0.0.1 or ::1 as the server name.
  • I CAN'T connect to the database through SSMS (or ADO.NET) if I specify localhost as the server name. I've tried both Windows and SQL Authentication The error I get is the standard

Can't connect to localhost. Additional Information --> Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. (Microsoft Sql Server)

Other considerations:

  • Stopping the Visual Web Developer web server from the taskbar doesn't affect the sql problem.
  • The SQL error log says that it's listening on some piped name url at start up (I don't see how this would affect localhost but not 127.0.0.1 though).

I could probably just use 127.0.0.1 everywhere, but it scares me that localhost isn't working and I'd like to figure out why.

I'm not much of a networking or sql server guy so I'm stuck. If you want me to try anything to help diagnose just put it in a comment and I'll give it a go.

Netstat results:

Setting SDK environment relative to C:\Program Files\Microsoft SDKs\Windows\v6.1

Targeting Windows Server 2008 x86 DEBUG

C:\Program Files\Microsoft SDKs\Windows\v6.1>netstat -ano | findstr 1434
  UDP    0.0.0.0:1434           *:*                                    6868
  UDP    [::]:1434              *:*                                    6868

C:\Program Files\Microsoft SDKs\Windows\v6.1>netstat -ano | findstr 1433
  TCP    0.0.0.0:1433           0.0.0.0:0              LISTENING       2268
  TCP    127.0.0.1:1433         127.0.0.1:50758        ESTABLISHED     2268
  TCP    127.0.0.1:50758        127.0.0.1:1433         ESTABLISHED     5008
  TCP    [::]:1433              [::]:0                 LISTENING       2268
  TCP    [::1]:1433             [::1]:51202            ESTABLISHED     2268
  TCP    [::1]:1433             [::1]:51616            ESTABLISHED     2268
  TCP    [::1]:51202            [::1]:1433             ESTABLISHED     5008
  TCP    [::1]:51616            [::1]:1433             ESTABLISHED     5008

C:\Program Files\Microsoft SDKs\Windows\v6.1>

SQL Server Log File:

In case it helps

2010-01-30 12:58:59.01 Server      Microsoft SQL Server 2008 (SP1) - 10.0.2531.0 (Intel X86) 
    Mar 29 2009 10:27:29 
    Copyright (c) 1988-2008 Microsoft Corporation
    Express Edition on Windows NT 6.0  (Build 6002: Service Pack 2)

2010-01-30 12:58:59.01 Server      (c) 2005 Microsoft Corporation.
2010-01-30 12:58:59.01 Server      All rights reserved.
2010-01-30 12:58:59.01 Server      Server process ID is 2268.
2010-01-30 12:58:59.01 Server      System Manufacturer: 'Dell Inc.', System Model: 'Inspiron 1545'.
2010-01-30 12:58:59.01 Server      Authentication mode is MIXED.
2010-01-30 12:58:59.02 Server      Logging SQL Server messages in file 'c:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\Log\ERRORLOG'.
2010-01-30 12:58:59.02 Server      This instance of SQL Server last reported using a process ID of 7396 at 1/30/2010 12:57:38 PM (local) 1/30/2010 5:57:38 PM (UTC). This is an informational message only; no user action is required.
2010-01-30 12:58:59.02 Server      Registry startup parameters: 
     -d c:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\master.mdf
     -e c:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\Log\ERRORLOG
     -l c:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\mastlog.ldf
2010-01-30 12:58:59.02 Server      SQL Server is starting at normal priority base (=7). This is an informational message only. No user action is required.
2010-01-30 12:58:59.02 Server      Detected 2 CPUs. This is an informational message; no user action is required.
2010-01-30 12:58:59.08 Server      Using dynamic lock allocation.  Initial allocation of 2500 Lock blocks and 5000 Lock Owner blocks per node.  This is an informational message only.  No user action is required.
2010-01-30 12:58:59.17 Server      Node configuration: node 0: CPU mask: 0x00000003 Active CPU mask: 0x00000003. This message provides a description of the NUMA configuration for this computer. This is an informational message only. No user action is required.
2010-01-30 12:58:59.30 spid7s      Starting up database 'master'.
2010-01-30 12:58:59.41 spid7s      Recovery is writing a checkpoint in database 'master' (1). This is an informational message only. No user action is required.
2010-01-30 12:58:59.67 spid7s      FILESTREAM: effective level = 0, configured level = 0, file system access share name = 'SQLEXPRESS'.
2010-01-30 12:58:59.92 spid7s      SQL Trace ID 1 was started by login "sa".
2010-01-30 12:58:59.94 spid7s      Starting up database 'mssqlsystemresource'.
2010-01-30 12:58:59.95 spid7s      The resource database build version is 10.00.2531. This is an informational message only. No user action is required.
2010-01-30 12:59:00.82 spid7s      Server name is 'DELL\SQLEXPRESS'. This is an informational message only. No user action is required.
2010-01-30 12:59:00.83 Server      A self-generated certificate was successfully loaded for encryption.
2010-01-30 12:59:00.84 Server      Server is listening on [ 'any'  1433].
2010-01-30 12:59:00.84 Server      Server is listening on [ 'any'  1433].
2010-01-30 12:59:00.84 spid10s     Starting up database 'model'.
2010-01-30 12:59:00.85 Server      Server local connection provider is ready to accept connection on [ \\.\pipe\SQLLocal\SQLEXPRESS ].
2010-01-30 12:59:00.86 Server      Server local connection provider is ready to accept connection on [ \\.\pipe\MSSQL$SQLEXPRESS\sql\query ].
2010-01-30 12:59:00.86 Server      Dedicated administrator connection support was not started because it is disabled on this edition of SQL Server. If you want to use a dedicated administrator connection, restart SQL Server using the trace flag 7806. This is an informational message only. No user action is required.
2010-01-30 12:59:00.87 Server      The SQL Server Network Interface library could not register the Service Principal Name (SPN) for the SQL Server service. Error: 0x54b, state: 3. Failure to register an SPN may cause integrated authentication to fall back to NTLM instead of Kerberos. This is an informational message. Further action is only required if Kerberos authentication is required by authentication policies.
2010-01-30 12:59:00.87 spid7s      Informational: No full-text supported languages found.
2010-01-30 12:59:00.87 Server      SQL Server is now ready for client connections. This is an informational message; no user action is required.
2010-01-30 12:59:00.91 spid7s      Starting up database 'msdb'.
2010-01-30 12:59:01.21 spid10s     Clearing tempdb database.
2010-01-30 12:59:02.78 spid10s     Starting up database 'tempdb'.
2010-01-30 12:59:03.30 spid13s     The Service Broker protocol transport is disabled or not configured.
2010-01-30 12:59:03.30 spid13s     The Database Mirroring protocol transport is disabled or not configured.
2010-01-30 12:59:03.31 spid7s      Recovery is complete. This is an informational message only. No user action is required.
2010-01-30 12:59:03.31 spid13s     Service Broker manager has started.

share|improve this question
    
Try "localhost\sqlexpress" –  GregD Jan 31 '10 at 17:55
    
No luck with server name "localhost\sqlexpress". Different error though. "A network-related or instance-specific error....server was not found or not accessible..." I also tried "{server name}\sqlexpress" which in my case is "DELL\sqlexpress", and got the same error. Just "DELL" gives me the error above ("Timeout expired...") –  Adam A Jan 31 '10 at 18:01
    
see Update1 in my answer –  Gennady Vanin Геннадий Ванин Aug 25 '10 at 12:37

7 Answers 7

Edited my answer based on your additional info.

I would follow all of the steps here and let us know.

share|improve this answer
    
1. I don't have this. I'm using SQL 2008 Express. Is there somewhere else I should look for 2008? 2. The SQLEXPRESS service is running as Network Service. Sql Server Browser is running as Local Service. 3. How can I check this? I'm not sure it could be the difference between localhost and 127.0.0.1 4. Created exceptions on the ports that sql service is running on (see question body). 1. 127.0.0.1 works. 2. What exception do I need for this? Just the UDP on port 1434? Got that one. 3. netstat shows TCP listening on 1433 and UDP on 1434. I'll post the result in the question. –  Adam A Jan 31 '10 at 18:17
    
I thought the connection from the 5XXXX ports were my SSMS connections using 127.0.0.1, but I closed SSMS and still see those. My Web Server isn't running AFAIK. –  Adam A Jan 31 '10 at 18:24
    
Ah just lingering. They're gone now. –  Adam A Jan 31 '10 at 18:25
    
edited my answer based on your input above –  GregD Jan 31 '10 at 23:58
    
I've already tried most of that as I listed above. I also checked that I was allowing remote connections (shouldn't matter anyway) but I already was. Remember, the problem is specifically that connecting to "localhost" fails, but connecting to "127.0.0.1" and "::1" both work. –  Adam A Feb 1 '10 at 3:42

You should use localhost\SQLEXPRESS to connect to the local instance of SQL Server - assuming the instance is called SQLEXRESS.

I noticed that in your comments you say that you are getting an error when you do this, can you please post it because it might help to solve your problem.

Also, instead of using 127.0.0.1 you can use .\SQLEXPRESS in your connection strings to connect to the local instance of SQL Server Express.

share|improve this answer
    
The error was along the lines of "A network-related or instance-specific error has occurred. The server was not found or not accessible". Anyway, I shouldn't have to use the name of the instance. I want my connection string to match between my local environment and my production environment. In other words, I want them both to point to simply "localhost". I think you guys are kind of missing the point anyway. using "127.0.0.1" works, but "localhost" doesn't. So the problem has to be something other than naming the instance. It's gotta be something related to the binding of "localhost". –  Adam A Feb 1 '10 at 3:30
    
You have to either put the instance name or the port number after the server name. SQLEXPRESS installs as a named instance by default, so the name in the connection string should be SERVERNAME\SQLEXPRESS or SERVERNAME, 1433. The error you are getting is a default message related to a timeout connecting to the instance. –  Jason Cumberland Jul 20 '11 at 20:43

Try enabling remote connections temporarily, it may be that SQL Server sees a hostname and thinks that it's a remote connection.

share|improve this answer
    
It's already enabled. –  Adam A Feb 1 '10 at 5:08
    
Ah you mean disabling? I'll give it a try... –  Adam A Feb 1 '10 at 5:08
    
No luck. Good idea though. –  Adam A Feb 1 '10 at 5:09

Some ideas...

  1. Have you checked your scope options for your firewall rules for UDP 1434? Try explicitly allowing localhost in a custom list.
  2. Have you tried disabling your firewall on your test server? I wonder if one of your rules has a funky scope option. Doubtful, but worth doing a test and posting the results as new information.
  3. Do you have any UDP services on the test server that you can try testing with? For example, setup an NTP server that syncs with something out on the Internet, and then setup your test server to sync its clock using that. If it works, you know "localhost" works, and your problem with localhost and SQL Server 08 Express is specific to the two.

Unfortunately, it doesn't look like you can easily do a localhost packet capture (so you're SOL there)...which would have been neat to see.

If you've already resolved this, I'd be curious to know what the answer was.

share|improve this answer

When you connect to the server in SSMS, what happens if you specify named pipes instead of TCP/IP as the network protocol in the Options, connection Properties?

here is my netstat, if it helps:

C:\Users\fff>netstat -ano | findstr 1433 TCP 0.0.0.0:1433
0.0.0.0:0 LISTENING 3680 TCP [::]:1433 [::]:0 LISTENING 3680

C:\Users\fff>netstat -ano | findstr 1434 TCP 127.0.0.1:1434
0.0.0.0:0 LISTENING 3680 TCP [::1]:1434 [::]:0 LISTENING 3680 UDP 0.0.0.0:1434
: 2644 UDP [::]:1434 : 2644

share|improve this answer

So a few minor issues here. Port 1434 UDP is for the SQL Server Browser service. This is like SQL DNS where it will map your request for a named instance to a port number. SQL assigns port numbers dynamically to the named instances and reserves 1433 TCP for the default installation, which I don't think Express does.

Please try this and report back your findings: 127.0.0.1,1433 localhost,1433 .,1433

This is the same as specifying the name. Open up SQL Profiler, and look for 'failed logins, successful logins' under the 'security audit' tab. This will show you if you're even connecting to the SQL Engine. If you don't see the log on attempt, you're not hitting the engine which means it's being blocked.

Can you try changing the port from 1433 to something else such as 11433 and report back? Did you remove the 0 in 'dynamic port' in SQL Configuration manager per network adapter? That could help too.

share|improve this answer

"My hosts file contains the default entries ("127.0.0.1 localhost" and "::1 localhost")"

Can you try to delete "::1 localhost" in HOSTS. For me it looks unnecessary and confusing (to which one localhost is supposed to resolve?). For ex., my HOSTS doesn't have it (only "localhost 127.0.0.1") and resolves localhost though differently

ping -a localhost resolves to ""::1" with network connection enabled and to 127.0.0.1 when network connection is disabled

Also, try to disable IPv6 on NIC TCP/IP properties or NIC connection just to narrow the area.

Waiting to hear your results!


Update1 (continuing to speak with myself, very exciting!):

share|improve this answer
4  
::1 is the IPv6 entry for localhost. It only appears in HOSTS files for operating systems that support IPv6. It is not unnecessary. –  MDMarra Aug 16 '10 at 11:15

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.