Skip to main content

Run SQL Server Workloads on PostgreSQL: Getting Started with Babelfish on FoundryDB

· 4 min read
FoundryDB Team
Engineering @ FoundryDB

Babelfish for PostgreSQL lets you run SQL Server applications against a PostgreSQL backend with minimal code changes. Your application connects on port 1433 using the standard TDS protocol, sends T-SQL, and Babelfish translates the queries into PostgreSQL internally.

FoundryDB now offers Babelfish as a fully managed service. This post walks through provisioning, connecting, and verifying a working instance using confirmed results from Babelfish 4.8.0 on PostgreSQL 16.11.

What You Get

  • Babelfish 4.8.0 on PostgreSQL 16.11
  • SQL Server 2014 wire protocol compatibility (version 12.0.2000.8)
  • TDS listener on port 1433
  • Standard PostgreSQL port (5432) available in parallel
  • Compatible with sqlcmd, SSMS, and any SQL Server driver

Prerequisites

  • A FoundryDB account and API credentials
  • Docker (for the sqlcmd examples below)

Step 1: Provision the Service

Use the FoundryDB REST API to create a Babelfish instance. The database_type is mssql and the version maps to the Babelfish release.

curl -u admin:YOUR_PASSWORD -X POST https://api.foundrydb.com/managed-services \
-H "Content-Type: application/json" \
-d '{
"name": "my-mssql",
"database_type": "mssql",
"version": "4.8",
"plan_name": "tier-2",
"zone": "se-sto1",
"storage_size_gb": 50,
"storage_tier": "maxiops"
}'

The response includes a service id. Hold onto it for the next steps.

Provisioning takes roughly 7 to 8 minutes. You can poll the status:

curl -u admin:YOUR_PASSWORD https://api.foundrydb.com/managed-services/SERVICE_ID \
| jq '{status: .status, host: .dns_records[0].full_domain}'

Wait until status is running.

Step 2: Get Your Credentials

The default database user is app_user. Retrieve the password:

curl -u admin:YOUR_PASSWORD -X POST \
https://api.foundrydb.com/managed-services/SERVICE_ID/database-users/app_user/reveal-password \
| jq .

The response includes the password in plaintext. Store it securely.

Step 3: Connect with sqlcmd

Use the official Microsoft mssql-tools Docker image to connect. Do not specify a -d (database) flag on the initial connection. Babelfish presents master, tempdb, and msdb as system databases and you will land in master by default.

docker run --rm mcr.microsoft.com/mssql-tools:latest \
/opt/mssql-tools/bin/sqlcmd \
-S "YOUR_HOST,1433" \
-U app_user \
-P "YOUR_PASSWORD" \
-Q "SELECT @@VERSION"

Expected output:

Babelfish for PostgreSQL with SQL Server Compatibility - 12.0.2000.8 / Apr 2 2026 15:14:12 / Copyright (c) Amazon Web Services / PostgreSQL 16.11 on x86_64-pc-linux-gnu (Babelfish 4.8.0)

Step 4: Explore the System Databases

Babelfish presents three system databases over TDS:

docker run --rm mcr.microsoft.com/mssql-tools:latest \
/opt/mssql-tools/bin/sqlcmd \
-S "YOUR_HOST,1433" \
-U app_user \
-P "YOUR_PASSWORD" \
-Q "SELECT name FROM sys.databases"

Output:

name
------
master
tempdb
msdb

These are logical databases. Under the hood, Babelfish runs in single-db mode: all TDS traffic is routed to the babelfish_db PostgreSQL database, with each logical database mapped to a schema.

Connection String Reference

For application drivers that accept a connection string (ADO.NET, JDBC, Go go-mssqldb, etc.):

sqlserver://app_user:PASSWORD@YOUR_HOST:1433

If your driver requires a database name:

sqlserver://app_user:PASSWORD@YOUR_HOST:1433?database=babelfish_db

Connecting via the PostgreSQL Port

Because Babelfish sits on top of PostgreSQL, you can also connect on port 5432 using any standard PostgreSQL client. The app_user account works on both ports.

PGPASSWORD=YOUR_PASSWORD psql \
"host=YOUR_HOST port=5432 user=app_user dbname=babelfish_db sslmode=require"

This is useful for administrative tasks or running PostgreSQL-native queries alongside your T-SQL workload.

A Note on TLS

Babelfish 4.8.0 on FoundryDB is compiled without OpenSSL, so TLS is not available on the TDS port (1433). The PostgreSQL port (5432) does support TLS. If encrypted SQL Server connections are a hard requirement for your workload, plan for this before migrating.

note

TLS support on port 1433 is a known limitation of Babelfish 4.8.0 on this platform. Use port 5432 with sslmode=require for encrypted administrative access until TLS on the TDS port is available.

What's Next

Now that you have a working Babelfish instance, consider these follow-on steps:


Ready to try it? Sign up for FoundryDB or deploy a Babelfish instance in your existing account from the dashboard.