Static IP guide
Connecting to Postgres with a static IP from a Java app on Heroku
JDBC has an underused option for this: the Postgres driver honors the socksProxyHost and socksProxyPort system properties, so a Java service on Heroku can reach an allowlisted Postgres server through Fixie Socks without any tunnel process. Alternatively, Fixie-Wrench gives you a localhost port and the JDBC URL just points there.
Recommended setup
Use Fixie Socks Heroku add-on for Postgres connections to a database that only accepts traffic from approved IP addresses. Store the proxy value in FIXIE_SOCKS_HOST, then configure Java to route outbound traffic through Fixie before connecting to Postgres.
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.
Forward a local port to Postgres through Fixie Socks
Good to know
- For the system-property route, also register a java.net.Authenticator with the SOCKS credentials, as shown in the Java docs.
- With the tunnel approach, the JDBC URL becomes jdbc:postgresql://
localhost:5432/yourdb and connection pools like HikariCP need no special handling.
Allowlist and test the static IPs
- Open the Fixie dashboard and copy the outbound IP addresses for this proxy.
- Add both IPs to the Postgres firewall or security group.
- Deploy the updated Java app on Heroku.
- Run a small connection test before sending production traffic.
Related guides
- Making API requests with a static IP from a Java app on Heroku
- Connecting to Postgres with a static IP from a Node app on Heroku
- Connecting to Postgres with a static IP from a Ruby app on Heroku
- Connecting to Postgres with a static IP from a Python app on Heroku
- Connecting to Postgres with a static IP from a Go app on Heroku
Related docs
- Java implementation examples
- Heroku setup documentation
- Postgres connection guide
- Fixie-Wrench for TCP forwarding
Is this guide useful?