Crucial Dynamics
Crucial Dynamics

Reputation: 11

Azure data studio will not reconnect to a locally hosted database

I recently set up a docker container to host SQL server 2017 on my Mac. I am using Azure data studio as the GUI for the connection. Below you will find a link to see exactly how I setup this connection. Upon establishing the connection everything works great. I can even disconnect and reconnect to the locally hosted database.

When I restart my computer I cannot seem to reconnect to the local host. I open terminal and see that I my sql server studio database is running. I open Azure data studio and it will not automatically connect. I go into Azure connection and I specify local host, username "sa", the password and the port number. Azure will not connect to the docker container and locally hosted database.

I receive the following error message: 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)

If someone could help me out I would really appreciate it. I do not have to rebuild what I have currently done for school each time I restart my machine. Thank you.

Setup link: https://adamwilbert.com/blog/2018/3/26/get-started-with-sql-server-on-macos-complete-with-a-native-gui

Upvotes: 1

Views: 6784

Answers (1)

Marc0
Marc0

Reputation: 191

You'll have to re-start the docker container before connecting to the server using Azure Data Studio.
Open a terminal window and execute the command to start the SQL server on docker

sudo docker run -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=YourStrong!Passw0rd' -p 1401:1433 --name sqlserver1 -d microsoft/mssql-server-linux:2017-latest

Next go to Azure Data Studio and connect to the database.

Upvotes: 1

Related Questions