How to fix provider: TCP Provider, error: 0 - The network location cannot be reached. for information about network troubleshooting see windows help

Amr_Ali 136 Reputation points
2022-03-26T10:07:38.95+00:00

Hello Everyone
My problem is so strange because I tried a lot of things but it was useless ..
I have an application developed by VB.net and SQL server 2012 installed on a machine with windows 7 everything was OK ,
When the client machine (SQL server) infected by ransomware virus . He formatted the whole disk but he found (3 backup files "NOT INFECTED" before format) . Now we have a clean HDD with new windows 10 home edition. I installed SQL Server 2017 EXPRESS on the machine and configured the firewall and user permission as I used to do with every project but I failed to make it work on this machine. another thing must be mentioned here that the error log of SQL server says something about "register of SPN" this error is not with me right now .
This machine with SQL server 2017 is stand alone "No Active Directory" it hosts the server only.

This is my connection string
Public cs As String = "Data Source=192.168.1.120\SQLEXPRESS,1433;Network Library=DBMSSOCN;Initial Catalog=ZStock; Persist Security Info=True;User ID=amr;Password=*******;Application Name=KMAStock;"

The Error says :
"""
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: TCP Provider, error: 0 - The network location cannot be reached. for information about network troubleshooting see windows help)
"""

Any suggestions

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,376 questions
0 comments No comments
{count} votes

Accepted answer
  1. Erland Sommarskog 107.2K Reputation points
    2022-03-26T12:55:40.703+00:00

    Forget about the databases. Your problem is that you are not reaching SQL Server, so whether there are databases or not is irrelevant.

    I note one thing that seems incorrect to me:

    Data Source=192.168.1.120\SQLEXPRESS*,1433*.

    1433 is the default port for a default instance. But you have a named instance, and a named instance will typically listen to another port. True, you may have configured the instance to listen to port 1433, and your post seems to indicate this.

    But if this is the case, you should simply say DataSource=192.168.1.120 and not specify instance name and port number. Also, be aware of that if you specify both instance name and port number, the instance name is ignored.

    Again, what you should focus on to reach SQL Server. Forget about backups, forget about the ransomware attack. You have installed SQL Server and now you are trying to connect it from - I assume - a remote machine.

    1 person found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. Erland Sommarskog 107.2K Reputation points
    2022-03-26T11:10:51.773+00:00

    The error means that you cannot reach SQL Server. Which could be for a number of reasons. You have the IP-address wrong, you have the instance name wrong, SQL Server is not running, there is a firewall in the way etc.

    Here is a link to a troubleshooter.

    The SPN thing in the error log may cause you problems later on, but not right now. You are not coming that far.

    1 person found this answer helpful.

  2. Erland Sommarskog 107.2K Reputation points
    2022-03-26T22:11:47.75+00:00

    A few observations:

    • You are running the RTM version. You should download and install the most recent Cumulative Update for SQL 2017 before you proceed.
    • SQL Server is indeed listening on port 1433.
    • According to the errorlog, SQL Server started at 22:26 Pacific time yesterday and was then shut down at 22:53. If this is the current errorlog, this means that SQL Server is not running. That could explain why connection fails.
    • There is a database ZStock on the machine. It seems that it was created/restored during this session for SQL Server.
    1 person found this answer helpful.