I’ve created a Hangfire job that connects to SQL Server.
The job runs fine on my local machine.
Next, I dockerized the job but it’s failing when trying to connect to Sql Server.
System.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’ve tried exposing the SQL Server ports in the Dockerfile and specified them in the docker run:
EXPOSE 80
EXPOSE 1433
EXPOSE 1434
EXPOSE 1434/UDP
EXPOSE 4022
EXPOSE 135
docker run -p 80:80 -p 1433:1433 -p 1434:1434 -p 1434:1434/UDP -p 4022:4022 -p 135:135 --name crm_workers crm_workers
I’ve tried using -P
I’ve changed the name of the connection string to use an IP address.
I’ve tried using --network host
All have failed to resolve the error.
Thoughts? Ideas?
Thank you