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:- Connection attempt from IP address
- IP checked against allowed list
- If not allowed: Connection blocked
- 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
Navigate to settings
Go to Database → Settings in your project dashboard
Find Network Restrictions
Scroll to the Network Restrictions section at the bottom
If you don’t see this section, update your PostgreSQL version in Settings → Infrastructure.
Add allowed CIDRs
Click Add restriction and enter:
- IPv4 CIDR: e.g.,
192.168.1.0/24 - IPv6 CIDR: e.g.,
2001:db8::/32
- 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)
Enable via CLI
Enable via Management API
IPv4 and IPv6 Considerations
Check your database IP version:- You have the IPv4 add-on enabled
- You have an IPv6 migration extension
Common CIDR Examples
| Use Case | IPv4 CIDR | IPv6 CIDR |
|---|---|---|
| Single IP | 203.0.113.5/32 | 2001:db8::1/128 |
| Small office | 203.0.113.0/24 | 2001:db8::/64 |
| Corporate network | 10.0.0.0/16 | fd00::/16 |
| Cloud provider region | 52.0.0.0/8 | 2600::/16 |
| Allow all (remove restrictions) | 0.0.0.0/0 | ::/0 |
Find Your IP Address
To whitelist your current IP:/32 (IPv4) or /128 (IPv6):
Remove Restrictions
Allow connections from any IP:- CLI
- Dashboard
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
Enable via CLI
Enable via Management API
PostgreSQL SSL Modes
PostgreSQL clients support different SSL modes:| Mode | Eavesdropping Protection | MITM Protection | Notes |
|---|---|---|---|
disable | No | No | Never use in production |
allow | Maybe | No | Falls back to unencrypted |
prefer | Maybe | No | Default, tries SSL first |
require | Yes | No | Requires SSL, doesn’t verify cert |
verify-ca | Yes | Depends | Verifies certificate authority |
verify-full | Yes | Yes | Recommended for production |
Using verify-full Mode
For maximum security, useverify-full:
Download CA certificate
- Go to Database → Settings
- Scroll to SSL Configuration
- Download prod-ca-2021.crt
- Node.js (pg)
- Python (psycopg2)
- Go
Limitations
Network Restrictions
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
Common Scenarios
Scenario 1: Development Team
Scenario 2: Cloud Application
Scenario 3: Multi-Region App
Troubleshooting
Connection refused after enabling restrictions
Connection refused after enabling restrictions
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 (
/32for single IP)
SSL connection failed
SSL connection failed
Error:
SSL connection has been closed unexpectedlySolution:- Update client to support SSL
- Use
sslmode=requireor higher - Download and install CA certificate for
verify-full - Check firewall allows SSL connections
Can't connect from Edge Function
Can't connect from Edge Function
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
IPv6 connection blocked
IPv6 connection blocked
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
