© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•10mo ago•
45 replies
jiheielf

✅ Docker Container Can't connect to remote SQL Server

Currently I have a Worker service that will interact with a sql server on a remote server. when it is deployed to my local machine, it works. But once I deploy it as a docker container, it fails the connection and printout this error
Main loop Exception: 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)
Main loop Exception: 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)

I have tried to search online from stackoverflow and in docker community, I have checked the firewall and tried different combinations compare to their post but it still did not work out...
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Cannot connect my application to sql server on docker.
C#CC# / help
16mo ago
how to connect to sql server?
C#CC# / help
4y ago
ASP.NET MVC How to open Database in SQL Server Management Studio (can't connect server)?
C#CC# / help
3y ago
Unable to connect to SQL
C#CC# / help
3y ago