Mssql login fail ECONNREFUSED 127.0.0.1:1433 - sql-server

while trying to log in using this .. mssql -u sa -p mypassword .i get this error, Error: Failed to connect to localhost:1433 - connect ECONNREFUSED 127.0.0.1:1433
I have installed sql server on docker using this https://www.microsoft.com/en-us/sql-server/developer-get-started/java-mac tutorial and started it.
I am using mac os sierra. I have searched all over internet including stackoverflow for this but gotten no answer. The only answer i get is to enable tcp/ip using sql configuration manager, but mac os doesn't have a configuration manager so I can enable the tcp/ip. Kindly assist.

I finally found the solution .. the docker set the memory as 2GB while the MS SQL server requires 3.25GB... All i had to do was go to the Docker preferences and changed the memory to 4GB and it works :). I was using sql server on docker on Mac.

I'm using docker to set up containers and then sql-cli to access SQL server. This is how I resolved that error which I got after providing mssql -u sa -p mypassword.
What I didn't realize at the beginning was a too simple password provided before with setting up a docker container:
docker run -d --name Homer -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=myPassw0rd' -p 1433:1433 microsoft/mssql-server-linux
The Terminal doesn't say this and only after going to docker > Kitematic and checking the logs of the just created container I saw such a security warning. I deleted that container and created a container with a strong password.
Then I got the error after I've started a wrong container (so the connection failed because I was trying to provide the password for a different container). Since then, I prefer to use Kinematic to manage and access my containers. Before I type mssql -u sa -p mypassword in the Terminal and start to work, I just go to docker > Kinematic and Start my container.

In my case the container exited due to an insecure mssql password.
Try reading the container logs.

In my case, I just needed to start the container.
docker start {container_name}

In my case (I was following this tutorial https://database.guide/how-to-install-sql-server-on-a-mac/) the problem was the host address.
I was trying to connect to localhost and I got the ECONNREFUSED message but then I realized that I needed to use the local IP docker assigned to the container (it was something like 192.168.xxx.xxx), so:
mssql -s 192.168..... -o 1433 -u sa -p 'mypassword'
finally worded.

I had the same, in my case I notice that the problem was the PORT, so:
1)Check if the container is running with
docker start "container_name"
2)Then, get the correct PORT with:
docker ps
3) Run it
mssql -s "PORT" -o 1433 -u sa -p "pwd"

I'm adding this answer to complement Krzysztof Tomasz's answer.
I was following this guide: How to Install SQL Server on a Mac
Everything was going well but at the time of connecting to the container with this command:
mssql -u sa -p mypass1
I got:
Error: Failed to connect to localhost:1433 - connect ECONNREFUSED
127.0.0.1:1433
Then I opened Docker app, clicked the container and in the Logs menu I could see the following:
2020-02-05 16:26:45.71 spid20s ERROR: Unable to set system
administrator password: Password validation failed. The password does
not meet SQL Server password policy requirements because it is too
short. The password must be at least 8 characters..
The password I set had only 7 chars. :o)
Now this makes sense.
This is also documented # Microsoft doc here:
Quickstart: Run SQL Server container images with Docker
Solved this problem by removing the container and launching it again...
As I only had one container I ran the following command:
docker rm $(docker ps -a -q)
Then launched sql server image again with a stronger password:
docker run -d --name sql_server_demo -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=MyPass11' -p 1433:1433 microsoft/mssql-server-linux

I resolved this issue by updating the port from 1422 to 1433, I used Kitematic to implement this update.

I had the same, and it was a RAM issue, HOWEVER... 4GB didn't do it for me, for some reason in my case I needed 6, then it worked.

Make sure you have started the container in docker.
Command to start a container: docker start container "containerName"
and then try to connect mssql

I had same problem too, after study the logs with two commands:
docker ps -a
then
docker logs 99373f58f2ff
I understood that problem is related to the password dose not to meet SQL Server password policy! That's is.

Related

Is it possible to connect with an Oracle Docker container with an ODBC?

I am using docker images from this github: https://github.com/oracle/docker-images
I installed oracle db version 19c in my environment with the following command:
docker run --name oracle19c --network host -p 1521:1521 -p 5500:5500
-v /opt/oracle:/u01/oracle oracle/database:19.3.0-ee
Then I connect to it to run sqlplus with:
docker exec -ti oracle19c sqlplus system/oracle#orclpdb1
SQL>
Then I managed to successfully load some data into it. However, I would like to connect to the database with an ODBC connection. However, I am confused on going about and connecting to the database inside docker, I have not been able to find any resources or guides. The server runs Ubuntu and I am connected over an ssh connection if that helps.
Edit:I tried with unixodbc but I would be willing to switch over to any other available options.

Can't Connect "SSMS on Windows" With "SQLServer on Linux" Container On Docker

I've pulled latest SQL Server docker image
docker pull mcr.microsoft.com/mssql/server
Then started with port 1400.
(I'm not using default port 1434 because I've a local instance of SQLServer running outside of docker which my SSMS can quickly connect)
docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=pa$$word#123" -e "MSSQL_PID=Express" --name "SQLServer" -p 1400:1400 -d mcr.microsoft.com/mssql/server
This is my container info
When I check the logs everything looks normal. But when I try to connect from SSMS, I'm getting the following error.
What could be the reason? I'm also planning to build a .NET Core application to connect to this docker image but now I've concerns regarding if it's some TLS version mismatch.
I found the solution. I need to specify the instance name in SSMS in order to connect to it

Can not connect to instance of SQL Server that is running in Docker container

I've downloaded and ran this Docker image mcr.microsoft.com/mssql/server:
docker run -d -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=Password!1" -p 1433:1433 --name sqlserver-test -d mcr.microsoft.com/mssql/server
up this point everything is OK.
Then I go to the SQL Server Management Studio and try to connect to localhost with user sa, but something is wrong because SSMS throws an exception that says something about network error.
Any ideas?
Try connecting to localhost, 1433 Also, confirm you don't have a real install of SQL Server on your machine trying to use port 1433. You might need to map port 1434->1433 and then connect with localhost, 1434

How to connect sql server using docker on mac?

I am trying to connect to sql server using docker. I have successfully enabled the container using this command
sudo docker run -d --name aakash -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=Maximus6hero#" -p 1434:1434 microsoft/mssql-server-linux
docker ps
3e41723b93d5 microsoft/mssql-server-linux "/opt/mssql/bin/sqls…" About an hour ago Up About an hour 1433/tcp, 0.0.0.0:1434->1434/tcp aakash
It shows that my container is running.
But when i try to connect using db visualizer it throws an error.
The TCP/IP connection to the host localhost, port 1434 has failed. Error: "The driver received an unexpected pre-login response. Verify the connection properties and check that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. This driver can be used only with SQL Server 2000 or later.". ClientConnectionId:6a802ae0-7203-411d-a599-4c1de997d843.
I also have windows pc with me, and i can connect easily using sql server management studio. Even i can connect others pc using that windows pc. But when i try to connect my mac to windows pc using its ip it also gives the same error.
I have enabled tcp/ip connection on windows using sql server configuration manager. But there is no such thing on mac.
You might be getting this error on your MAC because when you run the docker in the background, it uses only 2GB of memory by default which is insufficient to run the SQL server as it needs minimum of 3.25 GB and ideally, we should point it to 4GB of memory. Update the preferences section with above details on your docker. Save and restart the docker and you may check the below steps to see if that might help you for your MAC. I did this using Azure Data Studio and Docker.
Once you have Saved and restart the docker with 4GB of Memory Allocation for docker to run, all you'd need to do is pull the docker image of the sql server and download it. this can be done by below commands on your terminal . FYI, I am using bash commands below:
Command 1:
sudo docker pull mcr.microsoft.com/mssql/server:2017-latest
This will pull the latest vesion docker image and download. Once done, you need to set your SQL authentication on the server for your database. Follow below commands:
Command 2:
sudo docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=<SetYourPasswordHere>' \
-p 1433:1433 --name sql1 \
-d mcr.microsoft.com/mssql/server:2017-latest
This sets your password and uses the port 1433 for SQL server (which is the default port). To confirm if the image has been created and the SQL server is running on docker, execute the below command to check log(s).
Command 3:
docker ps
To check all instances in your history of dockers( i.e. if you already had dockers installed before you are attempting this SQL connection/execution), run the below command and it will give you all the logs of all instances you have created
Command 4:
docker ps -a
or
docker ps -all
Once, you have completed above steps and see that the docker has created SQL instance, you need to go to Azure Data Studio and set the below credentials to access the server that you just created above using Docker.
Server: localhost
Authentication Type: SQL Authentication
Username: sa
Password: <Check Command 2 to see what you entered in the password where it says SetYourPasswordHere>
Hope this helps in your tryst with running SQL server on your MAC. All the Best!

How to connect Docker with Azure Data Studio?

I install docker container on mac(OS X) and install Microsoft SQL 2017 image file on docker.So, I try to connect docker with Azure Data Studio but didn't connect it. Can I connect docker with Azure Data Studio and How to configure it? Please help me, thank a lot.
Use 127.0.0.1,1433 instead of 127.0.0.1:1433
This syntax is what my ASP.NET Core app uses as syntax so I figured MS liked that format for connection strings and such.
This worked for me. Hope it helps.
I was able to run SQL server on MAC using Docker by running it along with the Azure Data Studio.
In order to connect to a server, you need to go to preferences of your Docker settings and increase the Memory allocation from the default of 2GB to minimum 4GB (as SQL server needs min 3.25GB space). Save and restart the docker.
Once restarted, all you need to do is pull the docker image of the sql server and download it. this can be done by below commands on your terminal . FYI, I am using bash commands below:
Command 1:
sudo docker pull mcr.microsoft.com/mssql/server:2017-latest
This will pull the latest vesion docker image and download. Once done, you need to set your SQL authentication on the server for your database. Follow below commands:
Command 2:
sudo docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=<SetYourPasswordHere>' \
-p 1433:1433 --name sql1 \
-d mcr.microsoft.com/mssql/server:2017-latest
This sets your password and uses the port 1433 for SQL server (which is the default port). To confirm if the image has been created and the SQL server is running on docker, execute the below command to check log(s).
Command 3:
docker ps
To check all instances in your history of dockers( i.e. if you already had dockers installed before you are attempting this SQL connection/execution), run the below command and it will give you all the logs of all instances you have created
Command 4:
docker ps -a
or
docker ps -all
Once, you have completed above steps and see that the docker has created SQL instance, you need to go to Azure Data Studio and set the below credentials to access the server that you just created above using Docker.
Server: localhost
Authentication Type: SQL Authentication
Username: sa
Password: <Check Command 2 to see what you entered in the password where it says SetYourPasswordHere>
Hope this helps in your tryst with running SQL server on your MAC. All the Best!
You certainly can connect to a sql server image running in a docker container through azure data studio,
Based on the details mentioned in the question, I'm assuming that you have followed the steps on Microsoft docs for configuring sql server with docker,
The following command is needed to configure and run the SQL Server image docker container:
sudo docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=your-strong-password’ -p 1433:1433 -d mcr.microsoft.com/mssql/server:2017-latest;
To quickly verify
check that the image is running by running:
docker ps -a
And checking the status column (with the correct instance name) to be 'UP',
Then launch Azure Data Studio and fill the connection details:
If you have followed all the default settings in setting up the image, this should work for you,
Hope this helps,
I hope first you have installed sql-cli(make sure you have node.js installed in your system),
Then connect to Mssql with command -> mssql -u -p
try to connect/create a database with docker first then connect from Azure Data Studio

Resources