Method signature
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
port | number | Yes | The port number to get the host URL for |
Return value
Type | Description |
---|---|
string | The host URL that can be used to access the specified port in the sandbox |
Examples
Get Host for Web Server
Get Host for API Server
Get Host for Database Connection
Error handling
The method throws errors in the following cases:- Sandbox not active: When called without an active sandbox environment
- Unsupported sandbox: When called with unsupported sandbox environments (FlyIO, Modal)
- Invalid port: When the port number is invalid or out of range
Sandbox compatibility
Sandbox Type | Supported | Notes |
---|---|---|
E2B | ✅ Yes | Full support with automatic URL generation |
Daytona | ✅ Yes | Full support with automatic URL generation |
Cloudflare | ✅ Yes | Full support with automatic URL generation |
Northflank | ✅ Yes | Full support with automatic URL generation |
FlyIO | ❌ No | Port forwarding not yet implemented |
Modal | ❌ No | Port forwarding not yet implemented |
Use cases
- Web Development: Access development servers running in the sandbox
- API Testing: Get URLs for API servers to test endpoints
- Database Access: Connect to databases running in the sandbox
- Microservices: Access multiple services running on different ports
- Live Previews: Generate URLs for real-time preview of web applications
Notes
- Multi-Sandbox Support: This method is available for E2B, Daytona, Cloudflare and Northflank sandbox environments
- Automatic URL Generation: Supported sandboxes automatically generate secure HTTPS URLs for exposed ports
- Real-time Access: URLs are immediately accessible once the service starts on the specified port
- Security: All generated URLs use HTTPS and are scoped to the specific sandbox instance
- Port Range: Standard port ranges (1-65535) are supported
- No Port Validation: The method doesn’t validate if a service is actually running on the specified port