I am developing an ASP.NET web app on my Windows 11 machine. I have set up SQL Server Express to accept tcp connection, tested it using dbeaver and able to connect successfully.
But when I run my app, it cannot access the SQL Server Express instance:
fail: Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HMTN0TE9V55V", Request id "0HMTN0TE9V55V:00000013": An unhandled exception was thrown by the application.Microsoft.Data.SqlClient.SqlException (0x80131904): 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: 40 - Could not open a connection to SQL Server: Could not open a connection to SQL Server)
This is my connection string:
"LocalConnection": "Data Source=localhost;User ID=sa;Password=mypaswd;Initial Catalog=ABL;Encrypt=True; TrustServerCertificate=True; ",
and my dbeaver connection:
What could be wrong and how can I fix this?




Step 1: Go to Start->Run->Services.msc.
Once the Services are open, select SQL Server and start it, as per the given screenshot, given below:
Once you do it, SQL server will be up and running again.
Another method:
The Host may be incorrect. Here's what fixed the problem for me:
Step 1: Step 1: TCP/IP under SQLEXPRESS Protocols in SQL Server Network Configuration:
Step 2: Then, under IP Addresses, the IP4 or another IP field should be as shown in the picture below.
and
Step 3: SQL Server restarts.