Skip to main content
Supabase provides robust network security features to control who can connect to your database and how connections are secured. Configure IP restrictions to whitelist trusted networks and enforce SSL to ensure all connections are encrypted.

Network Security Overview

Protect your database with multiple layers of network security:

IP Restrictions

Whitelist specific IP addresses or CIDR ranges

SSL Enforcement

Require encrypted connections to PostgreSQL

API Protection

JWT-based authentication for all HTTP APIs

DDoS Protection

Built-in protection against abuse

IP Restrictions (Network Restrictions)

Network restrictions allow you to specify which IP addresses can connect to your PostgreSQL database and connection pooler.

How It Works

Restrictions are enforced before traffic reaches your database:
  1. Connection attempt from IP address
  2. IP checked against allowed list
  3. If not allowed: Connection blocked
  4. If allowed: Authentication required (must still have valid credentials)
Network restrictions apply to direct database connections and pooler connections, not HTTP APIs (PostgREST, Storage, Auth).

Enable via Dashboard

1

Navigate to settings

Go to DatabaseSettings in your project dashboard
2

Find Network Restrictions

Scroll to the Network Restrictions section at the bottom
If you don’t see this section, update your PostgreSQL version in SettingsInfrastructure.
3

Add allowed CIDRs

Click Add restriction and enter:
  • IPv4 CIDR: e.g., 192.168.1.0/24
  • IPv6 CIDR: e.g., 2001:db8::/32
Common examples:
  • Single IP: 203.0.113.5/32
  • Subnet: 203.0.113.0/24 (256 addresses)
  • All IPv4: 0.0.0.0/0 (no restrictions)
  • All IPv6: ::/0 (no restrictions)
4

Save changes

Click Apply to activate restrictions

Enable via CLI

Enable via Management API

IPv4 and IPv6 Considerations

If your database resolves to an IPv6 address, you must add both IPv4 and IPv6 CIDRs to the allow list.
Check your database IP version:
If you see both IPv4 and IPv6 addresses, add both:
Exceptions (only IPv4 needed):
  • You have the IPv4 add-on enabled
  • You have an IPv6 migration extension

Common CIDR Examples

Find Your IP Address

To whitelist your current IP:
Then add as /32 (IPv4) or /128 (IPv6):

Remove Restrictions

Allow connections from any IP:

SSL Enforcement

Enforce encrypted connections to your PostgreSQL database.

Why Enable SSL Enforcement

By default, Supabase allows both SSL and non-SSL connections for compatibility. Enforce SSL to:
  • Prevent eavesdropping: Protect credentials and data in transit
  • Prevent tampering: Ensure data integrity
  • Meet compliance: Required for SOC 2, HIPAA, etc.
  • Defense in depth: Additional security layer
HTTP APIs (PostgREST, Storage, Auth) always enforce SSL. This setting only applies to PostgreSQL connections.

Enable via Dashboard

1

Navigate to settings

Go to DatabaseSettings
2

Find SSL Configuration

Scroll to SSL Configuration section
3

Enable enforcement

Toggle Enforce SSL on incoming connections
4

Confirm reboot

Click Confirm (triggers brief database restart)
Enabling SSL enforcement triggers a database reboot:
  • Small projects: Few seconds
  • Large projects: A few minutes
  • Plan maintenance window accordingly

Enable via CLI

Enable via Management API

PostgreSQL SSL Modes

PostgreSQL clients support different SSL modes:

Using verify-full Mode

For maximum security, use verify-full:
1

Download CA certificate

  1. Go to DatabaseSettings
  2. Scroll to SSL Configuration
  3. Download prod-ca-2021.crt
2

Add to trusted CAs

3

Connect with verify-full

With connection libraries:

Limitations

Network Restrictions

Network restrictions currently only apply to:
  • Direct PostgreSQL connections
  • Connection pooler (Supavisor)
They do NOT apply to:
  • PostgREST (REST API)
  • Storage API
  • Auth API
  • Realtime
  • Supabase client libraries
Workarounds for HTTP APIs:
  • Use Row Level Security (RLS) policies
  • Implement application-level IP filtering
  • Use a CDN with IP restrictions (Cloudflare, etc.)
  • Deploy behind a VPN or private network

Edge Functions and Network Restrictions

Security Best Practices

1

Start restrictive

Begin with specific IPs, expand only as needed:
2

Enable SSL enforcement

Always enforce SSL in production
3

Use verify-full for critical apps

Maximum security with certificate verification
4

Combine with RLS

Network restrictions + RLS = defense in depth
5

Document your CIDRs

Keep a record of what each CIDR represents:
6

Review regularly

Audit and remove unused IP ranges quarterly

Common Scenarios

Scenario 1: Development Team

Scenario 2: Cloud Application

Scenario 3: Multi-Region App

Troubleshooting

Error: connection refused or timeoutSolution:
  • Verify your IP is in allow list
  • Check you added correct IP: curl https://api.ipify.org
  • Add both IPv4 and IPv6 if database uses IPv6
  • Ensure CIDR notation is correct (/32 for single IP)
Error: SSL connection has been closed unexpectedlySolution:
  • Update client to support SSL
  • Use sslmode=require or higher
  • Download and install CA certificate for verify-full
  • Check firewall allows SSL connections
Error: Edge Function times out connecting to databaseSolution:
  • Use Supabase client library (not direct postgres connection)
  • Or: Disable network restrictions
  • Or: Use PostgREST API from Edge Function
Error: Connection works sometimes, fails other timesCause: Database has IPv6, only IPv4 CIDR addedSolution:

Network Security Checklist

Before going to production:

Next Steps

Row Level Security

Implement database-level access control

Encryption

Understand data encryption in Supabase

Production Checklist

Complete pre-launch security review

Auth Security

Secure your authentication flows