Reputation:
I'm using SQL Server 2008 and in Visual Studio, in Server Explorer, I can connect to SQL Server running using my computer name, but I can't using 127.0.0.1 or localhost, shouldn't they be the same?
Also when using a connection string in the web.config file for the website I can't connect using localhost, but only with the computer name! Is there some setting I'm missing somewhere in the SQL Config Manager?
Upvotes: 50
Views: 101165
Reputation: 891
If someone followed this post and still hasn't solved their problems (like me), here's what solved it for me:
Step 1: I went to the TCP/IP line in SQL Server Network Configuration, under Protocols for SQLEXPRESS (though you should select your active sql server) and clicked on properties:
Step 2: Then, I made sure that under IP Addresses, the group IP4 is Enabled = "Yes", and that the TCP Port in there is set to 1433 (the default sql server port), like here:
Step 3: Lastly, just as a precaution, I've changed all the other IP group ports to 1433 also, and enabled = "Yes" them from IP2 to IP5 (I saw this one at another computer). I've also changed the IPAll's (the last group) TCP Port to 1433 as well. But that's just me. I'm crazy. Go crazy. It's good for you. Last, make sure Enabled is set to Yes on the protocol tab as well.
and then - Hooray! it worked. Cheers for all the good-hearted people that take their time to solve other people's problems.
Upvotes: 89
Reputation: 1299
You can also try: .\sql_server_instance_name
.\SQLExpress
Upvotes: 5
Reputation: 89
I had the same problem, and it looks like there were two issues.
First was implementing Rob's advice, ie to use the configuration manager to enable the SQL connections.
Second was to connnect to a specific instance, as advised by several folk. From the configuration manager I realised I had two instances, SQLEXPRESS and HOMEINSTALL. I could then make a connection using eg localhost\sqlexpress or .\homeintall.
Upvotes: 0
Reputation: 45771
You probably need to set Sql Server to allow "remote" connections:
Once the restart has completed, try connecting again - it should work now.
Upvotes: 19
Reputation: 94645
Use localhost\sql_server_instance_name
For example, localhost\sqlexpress
Use . instead of 127.0.0.1
.\sqlexpress
Upvotes: 9