Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure ngrok for SQL Server access

I would like to test a website in development hosted in a remote location against a sql server instance on my local machine. I was thinking I could run ngrok locally and update the connection string on the remote website appropriately, but I'm not sure what parameters I need to specify.

I've tried ngrok tcp 12345 and ngrok http 12345

In SQL Server Configuration Manager I've enabled TCP/IP for the SQL Express instance I want to use and set the port to listen on to 12345 (actually, a different number, but we'll say 12345 for the sake of this post). And I then restarted SQL Server.

I don't believe it's necessary for me to make holes in the firewall, but just in case I've temporarily disabled it entirely while I test this.

To test locally, I am taking the url ngrok provides and putting it in the connection dialog in SQL Management Studio, but I can't get it to connect.

What am I missing?

like image 415
BVernon Avatar asked Oct 21 '25 15:10

BVernon


2 Answers

  1. Set up Ngrok
  2. Run ngrok on tcp on the SQL port (by default is 1433) ngrok tcp 1433

You will get an url like tcp://3.tcp.ngrok.io:12345

In the "Connect to Server Dialog" type:

  • Server name: 3.tcp.ngrok.io,12345 Notice the comma between the port and the url. Type the url without tcp://
  • Login: your regular user, in my case sa and your password
  • Connect
like image 87
KABU09 Avatar answered Oct 25 '25 18:10

KABU09


The "URL" that ngrok generates for a TCP tunnel probably shouldn't be used unmodified. The tcp:// scheme part isn't a URI scheme in common use I don't think. Only the hostname and port part of the generated ngrok "URL" would be useful in a SQL Server connection configuration.

Not being intimately familiar with the referenced connection dialog in SQL Management Studio, it's hard to say exactly what input is expected, but maybe stripping out the tcp:// scheme will do the trick?

like image 40
Andrew Benton Avatar answered Oct 25 '25 18:10

Andrew Benton



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!