Docker to Docker ECONNREFUSED (Node-Red - to - SQL Server)

I have a Windows System.
Inside the Windows System, I have Virtual Box with Ubuntu
Inside the Ubuntu, I have installed Node-Red and SQL Server as dockers.

While being inside the Ubuntu,
I am able to work with Node-Red via localhost:1880
I am able to work with SQL-Server via localhost:1433 or 127.0.0.1 or 127.17.0.03:1433 or 127.18.0.3:1433 using the Azure Data Studio for Linux.

Considering the previous status, Node-Red & SQL Server are up and running, now i am trying to write from Node-Red to SQL Server table.

I have tried to use the MSSQL Node from node-red-contrib-mssql-plus:

  • using localhost:1433, I am getting: Failed to connect to localhost:1433 Could not connect (sequence)

  • using 127.0.0.1:1433, I am getting: Failed to connect to 127.0.0.1:1433 connect ECONNREFUSED 127.0.0.1:1433

  • using 127.17.0.3:1433, I am getting: Failed to connect to 127.17.0.3:1433 connect ECONNREFUSED 127.17.0.3:1433

  • using 127.18.0.3:1433, I am getting: Failed to connect to 127.18.0.3:1433 connect ECONNREFUSED 127.18.0.3:1433

I tried both with SA and with a user I created, both are working via Azure Data Studio
In addition, I have tried to add a bridge between these two containers and connect them in this new network.

Also noticed that if I try with 14XX I get the same error, and if I try with SQL stopped again I get the same error. Security issue? But why Azure studio have not a problem?
What I am missing?

----Update----
If I configure the mssql-node with the name of the container of the MSSQL is working.

  • Hostname: sql1
  • Port: 1433

Still not sure why its not working with ips

I am almost certain this is a docker setup issue.
You probably need to search "docker to docker communication" or ask on a docker forum I think (unless some docker wiz picks this question up)

I'm gonna edit the title so it gets correct exposure.

Yes you probably need to setup the docker networking correctly so that the simple name resolution will work. We have an example in the docs.

After so many hours, I figured out that if I configure the mssql-node with the name of the container of the MSSQL is working.

  • Hostname: sql1
  • Port: 1433

Still not sure why it's not working with ips

Hi, maybe the reason the Azure Studio is able to communicate, is because is installed in the host (Ubuntu)?

I tried to ping those different IPs/Ports and none of them are working, the only working IPs/Ports are:

  • localhost:1880 (NODERED)

  • 127.17.0.2:1880 (NODERED)

  • 127.18.0.2:1880 (NODERED)

  • sql1:1433 (SQL)