Fly.io

Fly.io Security Best Practices

Secure your Fly.io deployments with these essential practices. From secrets management to private networking.

Verify your app follows these best practices automatically.

Fly.io runs your apps at the edge with powerful security features. These practices help you leverage Fly's security capabilities effectively.

Quick Wins

Audit secrets with 'fly secrets list'
Switch to private networking for internal services
Verify TLS certificates are configured
Check which services are publicly accessible
Review database connection security

Security Best Practices

#1Use fly secrets for All Credentials

critical

Never include secrets in your Dockerfile or code. Use fly secrets set for all credentials.

Implementation

Run 'fly secrets set KEY=value' for each secret, never commit to code

Don't do this
ENV DATABASE_URL=postgres://user:pass@host/db
Do this instead
# In terminal: fly secrets set DATABASE_URL=postgres://user:pass@host/db

#2Use Private Networking

critical

Connect between Fly apps using private networking (.internal domains) instead of public endpoints.

Implementation

Use <app-name>.internal for inter-app communication, not public URLs

#3Configure Firewall Rules

high

Use Fly.io's firewall to restrict which IPs can access your services.

Implementation

Configure flycast for internal-only services, use connection handlers

#4Enable TLS for All Services

high

Ensure all public endpoints use TLS. Fly provides automatic certificates.

Implementation

Use fly certs for custom domains, verify HTTPS is working

#5Use Multi-Region Carefully

high

Multi-region deployments require careful consideration of data residency and consistency.

Implementation

Understand where your data lives, configure primary regions appropriately

#6Secure Database Connections

high

Connect to Fly Postgres via private networking, not public endpoints.

Implementation

Use internal connection strings, enable SSL for all database connections

Common Mistakes to Avoid

Secrets in Dockerfile

Why it's dangerous:

Docker images are stored and potentially accessible

How to fix:

Use 'fly secrets set' for all credentials

Using public URLs between services

Why it's dangerous:

Exposes internal traffic to the internet

How to fix:

Use .internal domains for inter-app communication

Exposing databases publicly

Why it's dangerous:

Database exposed to internet attacks

How to fix:

Use private networking for database access

Verify Your Fly.io App Security

Following best practices is the first step. Verify your app is actually secure with a comprehensive security scan.

Get Starter Scan

Frequently Asked Questions

Are fly secrets secure?

Yes, secrets are encrypted and only exposed to your running instances. They're not visible in the Fly.io dashboard after creation.

How do I connect services privately?

Use the .internal DNS suffix. Your app at 'myapp' is accessible at 'myapp.internal' from other Fly apps in your organization.

Is Fly.io Postgres secure?

Fly Postgres runs in your organization's private network. Use private connection strings and enable SSL for maximum security.

Last updated: January 2026