Problem with Credentials, SQL Server, N8N Docker

I filled credential fields with my server information but it is returning a timeout error when i try to connect, is the filling incorrect?

Server: 192.168.1.7
Database: DatabaseName
user: sql login
password: sql password
port: 1433
domain: HPMM   <<---- SELECT DEFAULT_DOMAIN()[DomainName];
That credential return me this error:
Failed to connect to 192.168.1.7:1433 in 150000ms
TLS on/off Both were tried and failed
Ignore SSL on/off Both were tried and failed
TDS version: 7_3_A (Sqlserver 2008)

It attempts to execute a JavaScript node. But ““Problem in node ‘Code in JavaScript1‘ Module ‘tedious’ is disallowed [line 3]””

const { Connection } = require('tedious');

const config = {
  server: '192.168.1.7',
  authentication: {
    type: 'default',
    options: {
      userName: 'sa',
      password: 'MyPass'
    }
  },
  options: {
    database: 'db',
    port: 1433,
    encrypt: false,
    connectTimeout: 15000
  }
};

const connection = new Connection(config);

connection.on('connect', (err) => {
  if (err) {
    console.error('Error detallado:', err);
  } else {
    console.log('Conexión exitosa!');
  }
  connection.close();
});

connection.on('error', (err) => {
  console.error('Error de conexión:', err);
});

connection.connect();

If I try to connect from the container, I can, the problem arises when I enable TLS. So the problem lies there.

docker exec -it n8n sh



cat > test.js << 'EOF'
const { Connection } = require('tedious');

const config = {
  server: '192.168.1.7',
  authentication: {
    type: 'default',
    options: {
      userName: 'sa',
      password: 'pass'
    }
  },
  options: {
    database: 'db',
    port: 1433,
    encrypt: false,
    connectTimeout: 15000
  }
};

const connection = new Connection(config);

connection.on('connect', (err) => {
  if (err) {
    console.error('❌ Error detallado:', err);
  } else {
    console.log('✅ Conexión exitosa!');
  }
  connection.close();
});

connection.on('error', (err) => {
  console.error('❌ Error de conexión:', err);
});

connection.connect();
EOF
node test.js

But when I connect through the node with TLS disabled, the error still occurs.

Share the output returned by the last node

Failed to connect to \192.168.1.7 in 15000ms

Information on your n8n setup

  • n8n version:

    2.9.4 (Self Hosted)

  • Running n8n via: Docker

  • Operating system of DB: Window server 2008

1 Like

Hi @gervabit84 Welcome to the community!
I recommend trying host.docker.internal instead of the 192.168.1.7 , and disable TLS in the credential settings

And i recommend reading this post:

Since the connection works fine from inside the container with tedious directly using encrypt: false, the network isn’t the problem, it’s how n8n’s MS SQL node passes those options to tedious under the hood. SQL Server 2008 is really old and newer versions of tedious default to requiring encryption which 2008 doesn’t support properly. Try adding NODE_TLS_REJECT_UNAUTHORIZED=0 as an environment variable in your docker-compose file and make sure you’re setting the TDS version to 7_3_A in the credential config, because if n8n defaults to a newer TDS version your 2008 instance will just hang and timeout instead of giving a useful error.