modal-networking
Skill4 starsChanged 3 months agoApache-2.0View on GitHub
Networking on Modal — proxies for static IPs, port forwarding, region selection, regional routing (Public Beta), and container networking. Use when configuring outbound IP addresses, exposing ports, selecting regions for latency, or connecting containers.
We split this skill into the rules it gives an agent
16 rules. About 0 are common, 12 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈12
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
Use this skill when configuring network behavior for Modal Functions, including static IPs, port forwarding, region selection, and …
- Distinctive: line 34
Create a Proxy in workspace Settings (Team/Enterprise plans)
- Distinctive: line 66
Run containers in specific geographic regions:
- Distinctive: line 130
Use Volumes, Dicts, or Queues for inter-Function communication
- Distinctive: line 145
Use Proxies with WireGuard tunnels
- Distinctive: line 147
All container traffic routes through the secure tunnel
- Distinctive: line 154
Create Sandboxes with network access (containers have outbound internet by default)
- Distinctive: line 155
Call deployed Functions that have networking configured in Python
- Very specific: line 157
Use sb.Exec() / sb.exec() to run networking tools inside Sandboxes
- Distinctive: line 176
Use a Proxy for static IP allow-listing
- Distinctive: line 177
Verify the proxy is online in workspace Settings
- Very specific: line 180
Use region= to run near the database
- Very specific: line 181
Use routing_region= (or .with_options(routing_region=...)) to route through a closer region
- Very specific: line 184
Use modal.forward(port) context manager
- Distinctive: line 185
Use Sandbox tunnels for Sandbox-based servers
- Distinctive: line 205
Use broader container regions for better availability and lower cost
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Modal Networking
Use this skill when configuring network behavior for Modal Functions, including static IPs, port forwarding, region selection, and inter-container communication.
For Server routing_region / compute_region on @app.server, see modal-servers. Auto Endpoints expose the same placement flags via CLI (modal-endpoints).
When to Use This Skill
- Need a static outbound IP for allow-listing
- Exposing internal container ports to the internet
- Running Functions near specific cloud regions
- Optimizing network latency with regional routing
- Connecting Functions to external private networks
Proxies (Static IP)
Route all container traffic through static IP addresses:
@app.function(proxy=modal.Proxy.from_name("my-proxy"))
def call_external_api():
import requests
# All traffic exits through proxy's static IP
return requests.get("https://api.example.com").json()Setup
- Create a Proxy in workspace Settings (Team/Enterprise plans)
- Each Proxy has up to 5 static IPs
- Allow-list these IPs in your firewall
With Sandboxes
sb = modal.Sandbox.create(
app=app,
proxy=modal.Proxy.from_name("my-proxy"),
)Port Forwarding (modal.forward)
Expose a container port to the internet temporarily:
@app.function()
def serve():
with modal.forward(8080) as tunnel:
print(f"Public URL: {tunnel.url}")
start_server(port=8080)
# Server accessible at tunnel.url while context is activeUseful for debugging, temporary services, or webhook receivers.
Region Selection
Container region
Run containers in specific geographic regions:
@app.function(region=["us-west"])
def west_coast_function():
...Available regions
| Broad | Narrow |
us | us-east, us-central, us-south, us-west |
eu | eu-west, eu-north, eu-south |
ap | ap-northeast, ap-southeast, ap-south, ap-melbourne, jp, au |
uk | — |
ca | — |
Broader regions are cheaper (1.5x) than narrow (1.75x).
Regional routing (Public Beta)
Control where Function inputs/outputs are routed (default us-east):
@app.function(routing_region="eu-west")
def eu_function():
...Valid routing_region values:
| Region | Location |
us-east | Virginia, USA (default) |
us-west | Oregon, USA |
ca-central | Montreal, Canada |
eu-west | Dublin, Ireland |
ap-south | Mumbai, India |
Beta constraints (still accurate for deploy-time config)
- Decorator
routing_region=is set at initial deploy; changing it on redeploy requires a new Function (cannot mutate in place). - Non-
us-eastrouting: invoke with.remote(),.map(), or HTTP for Web Functions (docs). Changelog also notes limited invoke methods during Beta. - Inputs/outputs >2 MiB still go through object storage in
us-east.
Dynamic override (SDK 1.5.2+)
Override routing at invocation time without redeploying:
f = modal.Function.from_name("my-app", "eu_function")
result = f.with_options(routing_region="us-west").remote(data)Also available on Cls.with_options(routing_region=...) (and Go/JS clients). This complements — does not remove — the deploy-time Beta constraints above.
Servers and Endpoints
@app.server uses routing_region (proxy anchor) and optional compute_region (container placement). Auto Endpoints use --routing-region / --compute-region. See modal-servers and modal-endpoints.
Container Networking
- Containers in the same App cannot directly connect to each other by IP (except in clusters)
- Use Volumes, Dicts, or Queues for inter-Function communication
- External network access is available by default
- DNS resolution works normally
Cluster Networking (Multi-Node)
Within @modal.experimental.clustered workloads:
- Nodes get unique IPv6 addresses on a shared 50 Gbps i6pn network
- RDMA available at 3200 Gbps when
rdma=True - Access peer IPs via
modal.experimental.get_cluster_info().container_ips - Designed for distributed training (e.g., PyTorch DDP, DeepSpeed)
Private Networking
For connecting to VPCs or on-premise networks:
- Use Proxies with WireGuard tunnels
- Configure proxy with your VPN/gateway IP
- All container traffic routes through the secure tunnel
Go/TypeScript SDK Note
Networking configuration (region selection, proxies, port forwarding, modal.forward()) is defined in Python Function decorators.
From Go/TS, you can:
- Create Sandboxes with network access (containers have outbound internet by default)
- Call deployed Functions that have networking configured in Python
- Override
routingRegionviawithOptionsat call time (SDK parity with Python 1.5.2+) - Use
sb.Exec()/sb.exec()to run networking tools inside Sandboxes
Sandbox-level network control from Go/TS:
sb, _ := mc.Sandboxes.Create(ctx, app, image, &modal.SandboxCreateParams{
BlockNetworkAccess: true, // disable outbound internet
})const sb = await modal.sandboxes.create(app, image, {
blockNetworkAccess: true,
});Symptom Triage
"External API rejects requests"
- Use a Proxy for static IP allow-listing
- Verify the proxy is online in workspace Settings
"High latency to external database"
- Use
region=to run near the database - Use
routing_region=(or.with_options(routing_region=...)) to route through a closer region
"Need to expose a development server"
- Use
modal.forward(port)context manager - Use Sandbox tunnels for Sandbox-based servers
"Cannot change routing_region on redeploy"
- Expected under Public Beta for decorator config — create a new Function, or use
.with_options(routing_region=...)at invoke time (1.5.2+)
Reference Map
references/proxies.md— Proxy setup, static IPs, WireGuardreferences/port-forwarding.md— modal.forward, tunnelsreferences/region-selection.md— container regions, regional routing (Public Beta),with_options, pricingreferences/container-networking.md— network behavior, DNS, inter-container comms- Sibling skills:
modal-servers(routing_region/compute_region),modal-endpoints
Guardrails
- Proxies require Team or Enterprise plan
- Region selection adds cost multipliers (1.5x–1.75x)
- Regional routing is Public Beta; deploy-time
routing_regioncannot be changed on redeploy (new Function required) - Dynamic
Function.with_options(routing_region=...)available from SDK 1.5.2+ - Non-
us-eastrouting has limited invoke methods (.remote/.map/ HTTP for Web Functions) - Use broader container regions for better availability and lower cost
- Proxy traffic is encrypted with WireGuard
- Large payloads (>2 MiB) still route object storage via
us-east
In this repository80 other files it gives its agents.
- a11y-accessibility-designSkill
- agentic-ui-patternsSkill
- ai-native-ui-designSkill
- ai-ui-anti-patternsSkill
- ai-ui-heuristicsSkill
- calm-technology-uiSkill
- conversion-growth-designSkill
- cross-platform-designSkill
- dark-mode-designSkill
- data-visualizationSkill
- design-systemsSkill
- design-thinking-processSkill
- error-empty-statesSkill
- ethical-design-patternsSkill
- form-uxSkill
- information-architectureSkill
- interaction-design-patternsSkill
- internationalization-uiSkill
- mobile-touch-designSkill
- modal-classes-lifecycleSkill
- modal-container-imagesSkill
- modal-dicts-queuesSkill
- modal-endpointsSkill
- modal-fundamentalsSkill
- modal-gpu-computeSkill
- modal-observabilitySkill
- modal-parallel-executionSkill
- modal-sandboxesSkill
- modal-scaling-performanceSkill
- modal-schedulingSkill
- modal-secretsSkill
- modal-serversSkill
- modal-storageSkill
- modal-web-servingSkill
- modal-workspace-adminSkill
- motion-design-principlesSkill
- notifications-permissionsSkill
- onboarding-uxSkill
- rust-api-designSkill
- rust-async-programmingSkill
- rust-cargo-masterySkill
- rust-cli-applicationsSkill
- rust-clippy-lintsSkill
- rust-closures-iteratorsSkill
- rust-compiler-internalsSkill
- rust-concurrencySkill
- rust-design-patternsSkill
- rust-editionsSkill
- rust-embeddedSkill
- rust-error-handlingSkill
- rust-game-developmentSkill
- rust-lifetimes-borrowingSkill
- rust-macrosSkill
- rust-performanceSkill
- rust-rustdocSkill
- rust-rustup-toolchainSkill
- rust-smart-pointersSkill
- rust-testing-benchmarkingSkill
- rust-type-systemSkill
- rust-unsafe-ffiSkill
- The first 60 shown.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

