I have an ASP.NET MVC project that I’ve containerized. Initially, I pulled a SQL Server image from Docker Hub and then modified the default connection as follows:
"ConnectionStrings": {
"DefaultConnection": "Server=mysql-container,3306;Database=ProductsDB;User Id=root;Password=my-secret-pw;"
},
However, upon attempting to access the project through localhost on my web browser, I encountered the following error:
SqlException: 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
I’m seeking guidance on resolving this issue.
I have containerized the project and ensured that both containers are running on the same network in Docker.
Usama Ikram is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.