sethserver.com Subscribe
AWS RDS MariaDB database connecting to Replit cloud IDE platform - Python database integration with cloud development environment for machine learning and NLP applications

How to Connect Replit to AWS RDS MariaDB in 20 Minutes | Step-by-Step Guide

By Seth Black • Updated: September 17, 2026

Programming · 5 min read

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

You can wire Replit to AWS RDS MariaDB in about 20 minutes. I've connected Replit to RDS MariaDB maybe a dozen times now, and it's always the same: 5 minutes of real work, and 15 minutes of staring at AWS wondering why my perfectly reasonable settings are being ignored.

This is mostly a networking problem wearing a database costume. Once you know the trick, it's stupid simple. Before you know the trick, it's maddening.

Also: use MariaDB. It's MySQL done right. Same protocol, same port, same drivers, fewer weird MySQL 8 auth plugin headaches, and it's not owned by Oracle. That last part matters more than people like to admit. I'm not being dramatic here. Oracle has a history of taking open-source projects and squeezing them for enterprise dollars. MariaDB is what happens when the original MySQL creators say "screw that" and fork it.

MariaDB vs MySQL: the part that trips people up

MariaDB is a drop-in replacement for MySQL in the ways you care about for an app connection:

So yes, you'll type mysql:// while connecting to MariaDB. No, it's not a betrayal.

Step 1: Create the RDS instance (and grab the right details)

In AWS RDS, create a MariaDB instance. Once it exists, you need:

Write them down somewhere. I know you think you'll remember. You won't. I've done this enough times to know that Future Seth will be mad at Present Seth for not copying that endpoint.

Step 2: Fix the security group (this is where dreams go to die)

RDS is locked down by default, which is correct from a security standpoint. But it also means your app will sit there timing out while you wonder what you did wrong. Nothing. You just haven't unlocked the door yet.

Go to:

RDS instance - Connectivity & security - VPC security groups - click the security group

Add an inbound rule:

The "Public accessibility" trap

If your RDS instance is not Publicly accessible = Yes, your security group changes won't help you from Replit. You'll be yelling at a firewall that isn't even listening. I've spent 30 minutes troubleshooting security group rules only to realize the instance wasn't publicly accessible. It's like trying to unlock a door that's also behind a wall.

So for initial setup/testing, set:

Then lock it back down later.

Production note: don't ship 0.0.0.0/0

Replit free plans don't give you a stable outbound IP. That means you can't safely whitelist "Replit" in AWS.

If you want to do this properly, you need a Replit plan that gives you a static outbound IP (Reserved VM or Dedicated VM), then replace 0.0.0.0/0 with that IP.

Otherwise you're leaving your database on the internet with a "please don't hack me" sign. Which is about as effective as you'd expect.

Step 3: Put credentials in Replit Secrets

In Replit, go to Tools - Secrets and add:

Or do a single URL:

DATABASE_URL = mysql://username:password@your-endpoint:3306/database_name

I prefer individual vars because when you need to rotate a password at 2am because someone committed credentials to GitHub, you don't want to be parsing connection strings. Ask me how I know.

Step 4: Connect from Python

Option A: mysql-connector (fine, common)

If you're doing MariaDB-specific stuff or you care about performance edges, use the official connector. But honestly? I usually just use mysql-connector because it's what I already have installed for other projects. It works fine.

import os
import mysql.connector

conn = mysql.connector.connect(
    host=os.environ.get("DATABASE_HOST"),
    user=os.environ.get("DATABASE_USER"),
    password=os.environ.get("DATABASE_PASSWORD"),
    database=os.environ.get("DATABASE_NAME"),
    port=int(os.environ.get("DATABASE_PORT", 3306)),
)

cur = conn.cursor()
cur.execute("SELECT 1;")
print(cur.fetchone())
cur.close()
conn.close()

Option B: native mariadb connector (also good)

If you want the official MariaDB connector, install and use it. If you just need queries to work, the MySQL drivers are usually enough.

Step 5: Connect from TypeScript / Node

Use mysql2. It behaves well, and it's battle-tested.

import mysql from "mysql2/promise";

const connection = await mysql.createConnection({
  host: process.env.DATABASE_HOST,
  user: process.env.DATABASE_USER,
  password: process.env.DATABASE_PASSWORD,
  database: process.env.DATABASE_NAME,
  port: parseInt(process.env.DATABASE_PORT || "3306", 10),
  ssl: { rejectUnauthorized: false },
});

const [rows] = await connection.execute("SELECT 1 AS ok;");
console.log(rows);
await connection.end();

Use a pool (yes, even if you're "just testing")

I've watched very smart people accidentally DDoS their own database by opening a new connection per request. I've also been that very smart person. Don't do that.

const pool = mysql.createPool({
  host: process.env.DATABASE_HOST,
  user: process.env.DATABASE_USER,
  password: process.env.DATABASE_PASSWORD,
  database: process.env.DATABASE_NAME,
  port: parseInt(process.env.DATABASE_PORT || "3306", 10),
  waitForConnections: true,
  connectionLimit: 10,
  queueLimit: 0,
  ssl: { rejectUnauthorized: false },
});

const [rows] = await pool.execute("SELECT NOW() AS now;");
console.log(rows);

Common failures (and what they actually mean)

One last thing: RDS costs money while it exists

AWS charges for uptime, not for your intentions. I learned this the expensive way when I left a test RDS instance running for three months. If this is a side project, stop or delete the instance when you're done. Future You will thank Present You. Your credit card definitely will.

-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