Mssql login fail ECONNREFUSED 127.0.0.1:1433

17,926

Solution 1

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.

Solution 2

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.

  1. 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.

  1. 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.

Solution 3

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

Solution 4

In my case, I just needed to start the container.

docker start {container_name}

Solution 5

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.

Share:
17,926
rosteve
Author by

rosteve

Blockquote

Updated on June 07, 2022

Comments

  • rosteve
    rosteve almost 2 years

    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.

  • Gary Woodfine
    Gary Woodfine about 7 years
    Thanks so much for taking the time tp post your own solution here. I spent ages trying to figure this out. My container was working previously even though it was set to 2GB. However when I updated Docker version it stopped running. So what I had to do in the end to get this working, was as you described set my memory to 4GB, and even though I clicked apply and restart. I still had to restart my mac for it to take effect, then all was working as per expected. My Docker Version 17.03.0-ce-mac2 (15654), if anyone else runs into this problem
  • Kannan Kandasamy
    Kannan Kandasamy about 7 years
    For me I am getting same error.. Also I did Docker preferences memory to 4GB and restarted machine... Still I am getting same error
  • Kannan Kandasamy
    Kannan Kandasamy about 7 years
    17.03.1-ce-mac5 Docker Version I have
  • rosteve
    rosteve about 7 years
    @KannanKandasamy what memory does your mac require to run docker?
  • Kannan Kandasamy
    Kannan Kandasamy about 7 years
    @ros not able to understand your question, My mac has 16 gb ram and In docker preferences i setup 4gb... As per sql server vnext documentation they are mentioning only 3.25
  • LW001
    LW001 about 6 years
    This does not provide an answer to the question. You can search for similar questions, or refer to the related and linked questions on the right-hand side of the page to find an answer. If you have a related but different question, ask a new question, and include a link to this one to help provide context. See: Ask questions, get answers, no distractions
  • Ruchira
    Ruchira about 5 years
    how to identify the container name ? @A. Juarez
  • NoughT
    NoughT about 5 years
    Most probably first you need to check the container is up and running. So in my case this solved the my issue. you can see all the containers using docker container ls -a
  • NoughT
    NoughT about 5 years
    docker container ls -a to see all containers. you will see a table and its' last column is names column.
  • rsenna
    rsenna about 5 years
    Same here... I had to use docker-machine ip to find out the IP assigned to the VM.
  • Rod Lima
    Rod Lima almost 5 years
    Hey @KannanKandasamy, maybe your problem is the password strength. I was looking my logs and saw this error: ERROR: Unable to set system administrator password: Password validation failed. The password does not meet SQL Server password policy requirements because it is not complex enough. The password must be at least 8 characters long and contain characters from three of the following four sets: Uppercase letters, Lowercase letters, Base 10 digits, and Symbols.
  • samurai_jane
    samurai_jane almost 5 years
    For anymore who's tried everything and still can't get past this. In my case, it was because the password was too complex– it appears that passwords with punctuation throw this error.
  • RoyalTiger
    RoyalTiger almost 5 years
    I faced a similar problem and got it resolved by following this answer. Thanks @ros. I would like to know the reason for such behavior.
  • Veronica
    Veronica over 4 years
    I did the same, but its not helping. Not sure why getting "Error: Failed to connect to localhost:1433 - connect ECONNREFUSED 127.0.0.1:1433"
  • Codedreamer
    Codedreamer almost 4 years
    This is the solution. Once i increase the size. I remove the container and try running the container again using the previous command. Eg, docker run -d --name sql_server -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=root' -p 1433:1433 microsoft/mssql-server-linux
  • Mohit Jain
    Mohit Jain over 2 years
    How would you specify the "PORT"? For example, I created the container using: -p 1002:1433 mcr.microsoft.com/mssql/server:2019-latest. When I try to run it using mssql -s 1002 -o 1433 -u sa -p "myPassword" I get an error saying that it can't connect to the port.