sethserver.com Subscribe
Cloud database integration workflow diagram showing data flow from cloud storage through database to web application interface for Python machine learning and NLP deployment

How to Connect Replit to AWS RDS SQL Server: Ports, Drivers, and Connection Strings

By Seth Black • Updated: September 17, 2026

Programming · 4 min read

Want more posts like this in your inbox? One email a week, no spam - subscribe to the newsletter.

You can spot someone who's only used Postgres from a mile away. They try to connect to SQL Server, confidently paste :5432 into a connection string, and then spend twenty minutes wondering why nothing works.

SQL Server is a solid database, but its connection details look like someone took a perfectly good connection string, ran it through a bureaucracy simulator, and then did it twice more for good measure.

If you're running an app on Replit and you need to hit AWS RDS SQL Server, here's the practical path. Just ports, security groups, and the occasional Linux driver nightmare.

Step 1: Get the RDS basics right (before you blame your code)

SQL Server on RDS listens on 1433 by default. Not 3306. Not 5432. 1433.

From your RDS instance page:

  1. Connectivity & security
  2. Confirm Public accessibility = Yes (for testing)
  3. Click the VPC security group link
  4. Add an inbound rule:
  5. Type: MSSQL
  6. Port: 1433
  7. Source: 0.0.0.0/0 (temporary, for testing)

Opening 0.0.0.0/0 is gross, but it's the fastest way to prove your code isn't the problem - the network is. Lock it down after you confirm connectivity.

About locking it down from Replit

On free Replit plans, your outbound IP can change. That means you can't safely whitelist a single IP in AWS.

If you want a stable outbound IP, you need a paid Replit option like a Reserved VM or Dedicated VM. Then you replace 0.0.0.0/0 with that static IP.

Step 2: Put connection details in Replit Secrets (don't build a URL yet)

SQL Server connection strings are their own special kind of weird. Store parts separately:

Keeping them separate means you don't have to invent some fake universal URL format that SQL Server will ignore anyway.

Step 3: Python option A - pyodbc (best if drivers cooperate)

Getting the Microsoft ODBC driver installed on Linux can be... an experience. Microsoft's Linux support is fine. It's fine.

If you can install ODBC Driver 18 for SQL Server, this is usually the most stable setup.

import os
import pyodbc

conn_str = (
    "Driver={ODBC Driver 18 for SQL Server};"
    f"Server={os.environ['DATABASE_HOST']},{os.environ.get('DATABASE_PORT','1433')};"
    f"Database={os.environ['DATABASE_NAME']};"
    f"UID={os.environ['DATABASE_USER']};"
    f"PWD={os.environ['DATABASE_PASSWORD']};"
    "Encrypt=yes;"
    "TrustServerCertificate=yes;"
    "Connect Timeout=30;"
)

with pyodbc.connect(conn_str) as conn:
    cur = conn.cursor()
    cur.execute("SELECT @@VERSION")
    print(cur.fetchone()[0])

Two quirks to notice:

Step 4: Python option B - pymssql (fallback when ODBC won't install)

If Replit's environment fights you on ODBC packages, pymssql is the "I just want this to work" solution.

import os
import pymssql

conn = pymssql.connect(
    server=os.environ["DATABASE_HOST"],
    user=os.environ["DATABASE_USER"],
    password=os.environ["DATABASE_PASSWORD"],
    database=os.environ["DATABASE_NAME"],
    port=int(os.environ.get("DATABASE_PORT", "1433")),
)

with conn.cursor() as cur:
    cur.execute("SELECT @@VERSION")
    print(cur.fetchone()[0])

conn.close()

It's simpler. Fewer moving parts. When you're trying to actually ship something, that matters more than architectural purity.

Step 5: TypeScript/Node - mssql package (works well)

Node's mssql library is actually pretty straightforward. Use encryption and trust the cert.

import sql from "mssql";

const pool = new sql.ConnectionPool({
  server: process.env.DATABASE_HOST!,
  port: Number(process.env.DATABASE_PORT || 1433),
  database: process.env.DATABASE_NAME!,
  user: process.env.DATABASE_USER!,
  password: process.env.DATABASE_PASSWORD!,
  options: {
    encrypt: true,
    trustServerCertificate: true,
  },
  pool: {
    max: 10,
    min: 0,
    idleTimeoutMillis: 30000,
  },
});

export async function queryVersion() {
  await pool.connect();
  const result = await pool.request().query("SELECT @@VERSION as version");
  return result.recordset[0].version;
}

Common failures (and what they usually mean)

One cost note (because your AWS bill will notice)

RDS SQL Server is usually more expensive than Postgres/MySQL/MariaDB at the same size. That's Microsoft licensing following you to the cloud.

If this is a side project, shut it down when you're not using it. If you're not locked into SQL Server for legacy reasons or T-SQL Stockholm syndrome, Postgres can handle most workloads and cost you less.

No shame if you need SQL Server. Just try not to write any cursors.

-Sethers

Share this post
Newsletter

One email, once a week.

Notes on databases, systems, and the occasional strong opinion about Python. No spam, unsubscribe anytime.

Seth Black
Written by

Seth Black

Engineer and founder based in Texas. Writes about databases, AI, and running things in production. Embeds in small teams as lead engineer.

More from Programming

View all →
Programming

What's the Differences Between Relational, NoSQL, Vectors, and Caches

Apr 14, 2026
Programming

Git and Source Control in AI Land

Apr 14, 2026
Programming

Domains, DNS, and why it feels fragile

Apr 14, 2026