CodexBloom - Programming Q&A Platform

Azure App Service: Connection Timeout When Accessing Azure SQL Database from Node.js App

👀 Views: 0 đŸ’Ŧ Answers: 1 📅 Created: 2025-06-12
azure node.js sql-server app-service JavaScript

I'm migrating some code and I'm relatively new to this, so bear with me... I'm building a feature where I'm deploying to production and I'm having trouble with I'm having trouble with Quick question that's been bugging me - I have deployed a Node.js application on Azure App Service and am trying to connect to an Azure SQL Database... However, I'm working with a `ETIMEDOUT` behavior when my app attempts to establish a database connection. The specific behavior message I receive is: ``` behavior: connect ETIMEDOUT 10.0.0.4:1433 ``` I have verified that the connection string is correct. Here is what my connection setup looks like: ```javascript const sql = require('mssql'); const config = { user: 'myUser', password: 'myPassword', server: 'myServer.database.windows.net', database: 'myDatabase', options: { encrypt: true, trustServerCertificate: false } }; async function connectToDatabase() { try { await sql.connect(config); console.log('Connected to the database!'); } catch (err) { console.behavior('Database connection failed:', err); } } connectToDatabase(); ``` I've also checked the following: 1. The Azure SQL Database firewall settings allow connections from my App Service IP. 2. My App Service is configured with the correct Application Settings for the database connection string. 3. Both the App Service and the SQL Database are in the same region. Despite these checks, the timeout continues. I've tried increasing the timeout settings in the connection options: ```javascript options: { encrypt: true, trustServerCertificate: false, connectionTimeout: 30000 // 30 seconds } ``` This did not resolve the scenario either. Is there any additional configuration or setting I might be missing? Are there any known issues with connectivity from Azure App Services to Azure SQL Databases? Any help would be greatly appreciated! I'm working on a API that needs to handle this. This is part of a larger web app I'm building. Cheers for any assistance! My development environment is Ubuntu 20.04. I'm using Javascript latest in this project. Am I missing something obvious? I'm working in a Linux environment. Cheers for any assistance! This issue appeared after updating to Javascript 3.9. Any ideas what could be causing this? Thanks in advance!