Unable to connect to MSSQL container through TCP Proxy
I was able to build and run a SQL Server database through a Dockerfile, exposing the standard port and providing the proper build arguments but am unable to connect after setting up a TCP Proxy (since this is a Docker-based deployment and not a supported Database Service it doesn't have a connection string if I understand right).
The error I first receive when trying to connect from SQL Server Management Studio is:
I also receive the error:
Is this a TLS issue? I've tried various combinations of encrypt and trust server certificate parameters but to no avail.
Solution:Jump to solution
if i where to use a dockerfile id use this
this would be the entire dockerfile, this one single line is all thats needed...
58 Replies
Project ID:
664eb8d7-2ff0-44d3-a9ab-537fd41b5746
664eb8d7-2ff0-44d3-a9ab-537fd41b5746
any reason for trying to deploy your own mysql service instead of railway's provided mysql template?
MSSQL = SQL Server
If it was MySQL I would've absolutely gone with a template. I'm mostly trying to avoid the pain that is Azure.
oh yeah sorry my bad
can you link me the docker image you are using to deploy a mssql server and I will see if I can get a template up and running for you
Hi Brody, sorry I forgot about this! Here is my Dockerfile:
does that run a windows based image?
mcr.microsoft.com/mssql/server:2019-latest
is an ubuntu-based image
https://hub.docker.com/_/microsoft-mssql-serverI assume you do have the EULA and password variables set?
Yes
can you send the deployment logs for the service? https://bookmarklets.up.railway.app/log-downloader/
Connection Details
Error Message:
A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host.)
screenshot of the public networking section of your service settings please
I honestly have no clue, try the other ports in the logs
1434
, 1431
hmm you mean like
EXPOSE
those ports as well in the Dockerfile, as well as TCP proxy them, then try it?the expose keyword does absolutely nothing on railway, I'm talking about with the tcp proxy
OK will give it a shot
something else that just popped into my mind, are you perhaps on a public network? they could be blocking non standard ports such as 29343
I'm at home, should be ok in that regard I think? 1433, 1434, 1431 all had the same error message
Error changes to:
The client was unable to establish a connection because of an error during connection initialization process before login. Possible causes include the following: the client tried to connect to an unsupported version of SQL Server; the server was too busy to accept new connections; or there was a resource limitation (insufficient memory or maximum allowed connections) on the server. (provider: SSL Provider, error: 0 - An existing connection was forcibly closed by the remote host.)
when changing connection parameter Encrypt to "strict"
I'm back to being out of ideas 😦
I don't see anything in the logs. Oh well, appreciate your help regardless. Was hoping to make this work to save some money and headache working with Azure.
I'll give this a try myself when I'm home
it worked!
Nice! What did you do differently?
uh idk, set the three variables the image wants and connected to it with dbgate
I only set two, accept_eula and sa_password. Can you share your Dockerfile?
Looks like you used SQL server 2022 image?
i dont use a dockerfile, but i did use the latest tag
Solution
if i where to use a dockerfile id use this
this would be the entire dockerfile, this one single line is all thats needed
How did you not use a Dockerfile? Is Microsoft SQL a database option now? I think when I last tried this months ago it wasn't which is why I went with docker
i deployed the image directly
I'm guessing there is an option to do that when setting up a new project?
no, the dashboard doesnt let you deploy an image from mcr, but thats besides the point
Lol I don't follow. How do I go about recreating what you did?
^
But if I understand, you're saying you deployed an image directly but I can't do that bc it's an MCR image?
correct
What can I do differently? Add that third variable?
I can use latest tag as well, I'm not pinned to 2019
2019 works fine
are you using the dockerfile i provided?
Are you thinking this is a networking thing on my end?
not sure, try dbgate, its free
I was using Azure Data Studio to test connection previously. I'll try dbgate
Alright I'll try the 1 line Dockerfile, add the missing variable you have, and connect w dbgate and get back to you
i omitted the variable and it still worked for me
Can I also try connecting to yours and see if it works?
sure, but does that mean dbgate wasnt working for you either?
Haven't got to the computer yet
Starting it now
While installing dbgate I was able to connect with azure data studio to yours
are you using the dockerfile I gave you?
Yes, just updated the repo and railway redeployed
Aaaand I'm connected
The one-line Dockerfile vs my original was the difference
awesome
This could be big! Railway already hosts an API for an azure SQL DB that costs the local govt I work for hundreds a month.
If I can replace that DB and colocated it with the API on railway, thats a financial and security win to me
Thanks a bunch man, really appreciate your help
if only railway supported deploying images directly from mcr
deploying a database from a repo just sounds ugly
even if its using the same image in the end
Yeah I feel ya, a repo for one file with one line to create a DB haha
but the dashboard only supports deploying images directly from dockerhub, ghcr, and quay