0

My SQL Server is on a local machine. I want to access it through internet. I created a website through I want to connect local SQL Server 2005.

This is the error message:

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

Thanks for a reply!

3
  • 1
    Are you trying to connect to SQL Server from a website running on the same machine or from a website running on another machine (through the Internet)? That's not clear from your question.
    – Massimo
    Aug 31, 2009 at 10:36
  • This seems to be a follow-up question to this one: serverfault.com/questions/60680/…
    – splattne
    Aug 31, 2009 at 11:37
  • No my Sql server is on a local network. And My Website is running on Internet.
    – Manish
    Aug 31, 2009 at 11:41

4 Answers 4

1

This is not the answer you are looking for, but... read it and think about it, at least if security is of interest.

You should never access an SQL Server from the internet due to the security risks, and I do not even recommend a solution where you place a webserver in DMZ and use an SQL server inside the firewall.

I would recommend you to place the webserver in one DMZ, the SQL server in a second DMZ and make sure the traffic to SQL server is only allowed from the first DMZ or from inside the firewall, never from the Internet.

If you really want to ignore recommendations, make sure you use a VPN tunnel from the Webserver and the SQL server, but remember it will not save you from SQL injections and you have to prevent it by yourself.

I have seen some examples, where it where possible to gain control of a webserver and use it to attack the SQL server with xp_cmdshell activated inside the firewall. Basicly it where possible to backup the complete database, send it somewhere and drop the database, and even use DEL . in the filesystem (with xp_cmdshell)

You can do a lot of nasty things with an SQL Server if you gain control over it.

0

Is the name you are using for the SQL Server instance resolvable on the internet.

Try to nslookup the name on your remote machine (where your web site is located):

nslookup servername.example.com

If the name doesn't resolve to an IP address, you could either use the public IP address of your network or set up a DNS entry for that name.

Did you check if your firewall/router is configured to forward the SQL Server ports to your internal SQL Server machine? Is there a software firewall on the server itself that must be configured?

1
  • I Check my firewall is off.
    – Manish
    Aug 31, 2009 at 11:42
0

To connect to your machine from another site you should use either the Machine IP address or machine name,

[MACHINENAME][INSTANCENAME] or [MACHINEIP][INSTANCENAME].

Also if your in a corporate environment it may be a problem if you are behind a firewall or proxy since your machine is not directly accessible from the outside, and the webserver might only be visible from the inside of the network. If your running everything on your machine ensure that you can see the machine from outside of the network.

Confirm that you can ping your machine from the Webserver. If you can then the Machine Name or IP Address should work, alternatively it means that your Webserver is outside your network, in which case the Sql Database will need to be hosted on the WebServer or another machine in the same network as the Webserver.

0

Other things that can cause this:

  • Your ISP might have your web server behind their firewall which might be blocking outgoing traffic on SQL Server port(s). Contact your ISP and see if this is the case.
  • If you are using a host name in your connection string it must be full-qualified (ie, "Server=mysqlserver.mydomain.com..." instead of "Server=mysqlserver").
  • Is your local sql server at your home or in an office? If it's at home and you're using an IP address in your web site's connection string it could be that your home IP address has changed. This often happens on DSL or cable lines when you don't sign up for a static IP address.

You must log in to answer this question.