---
title: "How to Connect Replit to AWS RDS MariaDB in 20 Minutes | Step-by-Step Guide"
description: "Learn how to connect Replit to AWS RDS MariaDB in 20 minutes. Step-by-step guide covering RDS setup, security group configuration, public accessibility settings, credential management, and connection code for Python and Node.js with common troubleshooting tips."
image: "https://cdn.sethserver.com/blog-images/connecting-your-replit-app-to-aws-rds-mariadb-social-1767152624.webp"
---

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

You can wire Replit to AWS RDS MariaDB in about 20 minutes. I've connected [Replit to RDS MariaDB](https://sethserver.com/programming/insanely-rapid-ai-assisted-development-with-replit.html) 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:

- Port is still **3306**
- Connection strings still look like `mysql://...`
- Drivers like `mysql2` and `mysql-connector` work fine
- Wire protocol is the same

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:

- **Endpoint** (looks like `your-db.abc123xyz.us-east-1.rds.amazonaws.com`)
- **Port** (default `3306`)
- **DB name**
- **Master username**
- **Master password**

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:

- Type: **MySQL/Aurora**
- Port: **3306**
- Source: **0.0.0.0/0** *(temporary)*

### 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:

- **Public accessibility: Yes**

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:

- `DATABASE_HOST`
- `DATABASE_USER`
- `DATABASE_PASSWORD`
- `DATABASE_NAME`
- `DATABASE_PORT` (optional, default 3306)

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.

```python
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.

```typescript
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.

```typescript
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)

- **Timeout / can't connect**: It's the security group or public accessibility. I want to say "always" but I've been wrong before. It's almost always one of those two.
- **Access denied for user**: wrong creds, or user doesn't have permissions.
- **Unknown database**: you didn't create it. Connect without `database=...`, then:
  `sql
  CREATE DATABASE your_database_name;`
- **Too many connections**: you didn't pool, or you forgot to close connections.
- **SSL complaints**: RDS can require encryption. Start with `rejectUnauthorized: false` for testing, then do it properly.

## 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


```json
{"@context": "https://schema.org", "@type": "BlogPosting", "headline": "How to Connect Replit to AWS RDS MariaDB in 20 Minutes | Step-by-Step Guide", "datePublished": "2025-12-11T07:29:30", "dateModified": "2026-09-17T19:47:52", "image": {"@type": "ImageObject", "url": "https://cdn.sethserver.com/blog-images/connecting-your-replit-app-to-aws-rds-mariadb-social-1767152624.webp", "width": 400, "height": 400}, "url": "https://www.sethserver.com/programming/connecting-your-replit-app-to-aws-rds-mariadb.html", "author": {"@type": "Person", "name": "Seth Black", "url": "https://www.linkedin.com/in/seth-black-tx"}, "publisher": {"@type": "Organization", "name": "Sethserver", "logo": {"@type": "ImageObject", "url": "https://www.sethserver.com/static/images/PaperAirplane512.png"}}, "description": "Learn how to connect Replit to AWS RDS MariaDB in 20 minutes. Step-by-step guide covering RDS setup, security group configuration, public accessibility settings, credential management, and connection code for Python and Node.js with common troubleshooting tips.", "articleSection": "Technology"}
{"@context": "https://schema.org", "@type": "BreadcrumbList", "itemListElement": [{"@type": "ListItem", "position": 1, "name": "sethserver", "item": "https://www.sethserver.com/"}, {"@type": "ListItem", "position": 2, "name": "Programming", "item": "https://www.sethserver.com/programming/"}, {"@type": "ListItem", "position": 3, "name": "How to Connect Replit to AWS RDS MariaDB in 20 Minutes | Step-by-Step Guide", "item": "https://www.sethserver.com/programming/connecting-your-replit-app-to-aws-rds-mariadb.html"}]}
```
