Static IP guide
Connecting to MySQL with a static IP from a Node app on Heroku
MySQL grants are commonly restricted by host, and cloud MySQL firewalls (RDS, Cloud SQL, Azure Database) expect a fixed caller address — something a Heroku dyno cannot promise. With Fixie Socks, mysql2 accepts a SOCKS connection as its stream, so your app presents Fixie's static IPs to the database while the driver API stays the same.
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 Node.js 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
Implementation
The example below shows the core application-side change. Keep credentials in environment variables and avoid committing proxy, database, or API secrets.
Connect to MySQL through FIXIE_SOCKS_HOST
Good to know
- Use a connection pool — pooling is already a best practice for this kind of workload and keeps reconnects out of your query path.
- The database sees Fixie's IP, not the dyno's — so host-restricted grants and firewall rules should reference the two IPs from your Fixie dashboard.
Allowlist and test the static IPs
- Open the Fixie dashboard and copy the outbound IP addresses for this proxy.
- Add both IPs to the MySQL firewall or security group.
- Deploy the updated Node.js app on Heroku.
- Run a small connection test before sending production traffic.
Related guides
- Making API requests with a static IP from a Node app on Heroku
- Connecting to MySQL with a static IP from a Node app on Vercel
- Connecting to MySQL with a static IP from a Ruby app on Heroku
- Connecting to Postgres with a static IP from a Node app on Heroku
- Connecting to MySQL with a static IP from a Python app on Heroku
- Connecting to MongoDB with a static IP from a Node app on Heroku
Related docs
- Node.js implementation examples
- Heroku setup documentation
- MySQL connection guide
- Fixie-Wrench for TCP forwarding
Is this guide useful?