Static IP guide

Connecting to MySQL with a static IP from a Python app on Heroku

Whether you use mysqlclient, PyMySQL, or Django's MySQL backend, none of them speak SOCKS — so on Heroku the reliable approach is a Fixie-Wrench tunnel on localhost:3306. Your settings point at localhost; the allowlisted server sees only Fixie's static IPs.

RuntimePython
PlatformHeroku
DestinationMySQL
Fixie productFixie Socks Heroku add-on

Recommended setup

Use Fixie Socks Heroku add-on for MySQL or MariaDB connections from a dynamic hosting platform. Store the proxy value in FIXIE_SOCKS_HOST, then configure Python to route outbound traffic through Fixie before connecting to MySQL.

Set up Fixie on Heroku

Heroku is a native Fixie marketplace flow. Install the Fixie Socks Heroku add-on or attach it from the Heroku CLI. Heroku will create FIXIE_SOCKS_HOST as a config var for the app.

Attach fixie-socks to your Heroku app

heroku addons:create fixie-socks
heroku config:get FIXIE_SOCKS_HOST

Implementation

The example below shows the core application-side change. Keep credentials in environment variables and avoid committing proxy, database, or API secrets.

Forward a local port to MySQL through Fixie Socks

# Install Fixie-Wrench in your app build or deploy process.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/usefixie/fixie-wrench/HEAD/install.sh)"

# Start a tunnel from localhost:3306 to mysql.example.com:3306.
# Your Python app connects to localhost:3306; Fixie handles the outbound static IP.
./bin/fixie-wrench 3306:mysql.example.com:3306

Good to know

  • Set the connection host to 127.0.0.1 and keep TLS options as-is; the encrypted session passes through the tunnel untouched.
  • Cloud MySQL firewalls (RDS security groups, Cloud SQL authorized networks, Azure firewall rules) need both Fixie IPs added.

Allowlist and test the static IPs

  1. Open the Fixie dashboard and copy the outbound IP addresses for this proxy.
  2. Add both IPs to the MySQL firewall or security group.
  3. Deploy the updated Python app on Heroku.
  4. Run a small connection test before sending production traffic.

Related guides

Related docs