I have developed a test site in asp.net. While it is in running of the in built webserver it functions fine and am able to access the database (msde). But when i host it on IIS server on the same machine I get the following error whenever the site accesses the database:

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)

How do I overcome this error.

The connection string in my web.config is as follows:

<connectionStrings>
        <add name="Cloud" providerName="System.Data.SqlClient" connectionString="server=naheed-pc1\mycloudflash;database=cloud;uid=sa;pwd=!cloud.123" />
    </connectionStrings>

Please assist.

Dani AI

Generated

Short, practical diagnostic and fix list (builds on and ):

When an app runs fine under the Visual Studio development server but fails under IIS with an instance-not-found symptom (error 26), the root causes are usually instance resolution (named instance lookup), the instance’s network protocols being disabled, or a firewall blocking the SQL Browser or the instance port. Confirm the exact instance name in SQL Server Management Studio on the same machine as the app before changing anything. ()

Checklist to resolve the common causes

  • From the database host: enable TCP/IP for the instance in SQL Server Configuration Manager and restart the SQL service.
  • For named instances either start SQL Server Browser (so clients can discover the port) or assign a fixed TCP port and use server,port in the connection string.
  • Open the Windows Firewall for the instance TCP port (default 1433 if used) and for UDP 1434 (SQL Browser) when the Browser service is required.
  • If using SQL authentication, ensure the server is configured for mixed mode; if using Windows auth, ensure the app’s Windows identity has a SQL login. (learn.microsoft.com)

App-pool identity and DB permissions

  • IIS app pools often run as an ApplicationPoolIdentity (or Network Service on older setups). Grant the actual app identity a SQL Server login and map it to the database with only the roles needed. Example T‑SQL (run as an admin in SSMS or sqlcmd):
CREATE LOGIN [IIS APPPOOL\MyAppPool] FROM WINDOWS;
USE MyDatabase;
CREATE USER [IIS APPPOOL\MyAppPool] FOR LOGIN [IIS APPPOOL\MyAppPool];
ALTER ROLE db_datareader ADD MEMBER [IIS APPPOOL\MyAppPool];
ALTER ROLE db_datawriter ADD MEMBER [IIS APPPOOL\MyAppPool];

This follows the ApplicationPoolIdentity model. (learn.microsoft.com)

Quick tests and safety notes

  • From the app server try:
    sqlcmd -L
    Test-NetConnection DBHost -Port 1433
    netstat -anb
  • Check the SQL error log for the “Server is listening on” line to see the actual port. Avoid shipping hard‑coded sa credentials in web.config — prefer a least‑privilege SQL account or properly-mapped Windows identity. (learn.microsoft.com)

These steps cover the usual gap between the VS dev server (local/shared‑memory connects) and IIS (networked/named‑instance) deployments.

Recommended Answers

All 3 Replies

hello.
it happen to me i think for long time ago,so what i can tell you that is sql security,go to sql server to security then you have NT AUTHORITY\NETWORK SERVICE then properties and go to user mapping,check your database name and choose a database role like public and try now.if it didn't work try NT AUTHORITY\SYSTEM and do the same thing.
really i can't remember,but at least i direct you.
hope this will help you.

Please check if you are able to connect using sql server management studio on the same name "naheed-pc1\mycloudflash" if not, then use the same name as shown in the sql server management studio

Hi all. thanks for your responses. I was finally able to resolve the problem by installing full sql version and using the tools to configure remote access to the database.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.