Firewall
Every port on a new instance is reachable from the internet by default. A firewall limits incoming connections to the ports you list, so a Jupyter server or an inference endpoint is not exposed by accident. This page covers the rules, which providers support them, and how to set them in the dashboard and through the API.
How the firewall works
There are two modes:
- All ports open: the default. Anything listening on the instance can be reached.
- Only these ports: only the ports you list accept incoming connections. Every other incoming connection is blocked.
Outbound traffic and ping stay allowed in both modes, so the instance can still download packages, models and datasets.
Each rule has three parts:
| Part | Values | Example |
|---|---|---|
| Protocol | TCP or UDP | TCP |
| Ports | One port, or a range where the provider supports it | 22, 8000-8100 |
| Source | Anywhere, one IPv4 address, or an IPv4 range (CIDR) | 203.0.113.0/24 |
An instance can have up to 50 rules.
Provider support
| Provider | When you can set it | Port ranges |
|---|---|---|
| Spheron AI (most machines) | At deploy, and on a running instance | Yes |
| Spheron ES | At deploy, and on a running instance | No, single ports only (up to 64 in all) |
| Spheron MS | At deploy only | Yes |
| Other providers | Not available |
Not every Spheron AI machine supports a firewall. The dashboard shows it only on offers and instances that do. Through the API, check extras.capabilities.firewall on an offer and instanceFeatures.firewall on a deployment.
Set a firewall when you deploy
- Open Deploy GPUs or Deploy CPU, pick an offer and choose Next.
- In the Firewall card on the SSH Key step, choose Only these ports.
- Keep the TCP 22 rule so you can connect over SSH.
- Choose Add a rule for each extra port, for example TCP
8000for an inference server. - Optionally, set a source to allow only your own network, for example
203.0.113.0/24. - Deploy the instance.
The firewall is in place before the instance boots, so the instance is never open in the meantime.
Change the firewall on a running instance
- Open Instances.
- Open the instance's menu and choose Firewall.
- Edit, add or remove rules, or switch back to All ports open.
- Choose Apply rules.
The change applies within a minute. On Spheron MS, the same item shows the rules set at deploy, read only.
Keep one-click apps reachable
A one-click app needs its port open: Jupyter 8888, vLLM 8000, SGLang 30000 or Open WebUI 8080. ComfyUI and the Ollama API are reached through an SSH tunnel, so they need TCP 22. A deploy with an app and an Only these ports firewall that leaves out the app's port is refused, and the message names the port to add. A rule from your own IP address counts.
Keep SSH reachable
Without a TCP 22 rule, you cannot connect over SSH. If you remove it, the dashboard warns you, asks you to confirm, and offers to add the rule back. Through the API, a restricted firewall with no TCP 22 rule returns 400 firewall_ssh_unconfirmed unless the request also sends confirmSshRemoval: true.
Use firewalls with AI connections
Assistants connected through AI connections can set a firewall when they deploy an instance, and change it later where the instance supports live changes.
Use the API
Send firewall on POST /api/deployments to set it at deploy, and PUT /api/deployments/{deploymentId}/firewall to change it on a running instance. See Set firewall.
# Allow SSH from anywhere and port 8000 only from your own network
curl -X PUT https://app.spheron.ai/api/deployments/<deployment-id>/firewall \
-H "Authorization: Bearer <your-api-key>" \
-H "Content-Type: application/json" \
-d '{
"firewall": {
"mode": "restricted",
"rules": [
{ "protocol": "tcp", "ports": "22" },
{ "protocol": "tcp", "ports": "8000", "source": "203.0.113.0/24" }
]
}
}'To open every port again, send { "firewall": { "mode": "open", "rules": [] } }.
What's next
- Networking: Public IPs, port access and SSH tunneling
- Security best practices: Secure your instances and data
- Saved images: Deploy new instances from a saved setup
- API reference: The firewall endpoint and fields
Troubleshooting
Issue: The Firewall card or menu item is missing
Symptoms: No Firewall card on the SSH Key step, or no Firewall item in the instance menu.
Diagnosis: The offer or instance is on a provider without firewall support.
Resolution: Use the Spheron AI provider, Spheron ES or Spheron MS, or restrict ports with ufw inside the instance.
Issue: A port range is refused
Symptoms: The rule shows "this provider takes single ports only". Diagnosis: Spheron ES accepts single ports only. Resolution: List each port as its own rule.
Issue: SSH times out after changing the firewall
Symptoms: ssh hangs, then times out.
Diagnosis: The rules have no TCP 22 rule, or its source does not include your IP address.
Resolution: Open the instance's Firewall from the dashboard and add TCP 22 from anywhere, or from a range that includes your address.