Proxy Configuration
OpenCode respects standard HTTP proxy environment variables for all outbound connections to LLM providers, APIs, and external services.Basic Setup
Environment Variables
HTTPS proxy URL (recommended for encrypted proxy connections).
HTTP proxy URL (fallback if HTTPS_PROXY not set).
Comma-separated list of hosts to bypass proxy. Must include
localhost,127.0.0.1 for OpenCode to function.Generic proxy for all protocols (least specific, use HTTPS_PROXY/HTTP_PROXY when possible).
Proxy Authentication
Include credentials directly in the proxy URL:Advanced Authentication Methods
For proxies requiring NTLM, Kerberos, or certificate-based auth:Deploy an LLM Gateway
Use tools like LiteLLM Proxy or Kong that support advanced authentication.
Configure OpenCode to use the gateway
Point OpenCode to your gateway instead of directly to LLM providers:
opencode.json
Proxy Debugging
Verify proxy connectivity:Common Proxy Issues
Common Proxy Issues
TUI won't connect to server
TUI won't connect to server
Cause:
NO_PROXY not set, routing localhost through proxy.Fix:SSL certificate verification fails
SSL certificate verification fails
Cause: Proxy performs SSL interception with custom CA.Fix: Add custom CA certificate (see Custom Certificates section).
Proxy authentication errors
Proxy authentication errors
Cause: Special characters in password not URL-encoded.Fix: URL-encode password:
Custom CA Certificates
Enterprise networks often use custom Certificate Authorities (CAs) for SSL/TLS inspection. Configure OpenCode to trust these certificates.Single Certificate File
This variable is read by Node.js/Bun’s TLS stack and applies to:
- Proxy connections (if using HTTPS proxy)
- Direct HTTPS requests to LLM providers
- Any other HTTPS traffic from OpenCode
Multiple Certificates
Concatenate multiple CA certificates into one file:Certificate Locations
Common enterprise CA certificate locations:Persistent Configuration
Add to your shell profile for persistence:Certificate Verification Issues
Troubleshooting SSL Errors
Troubleshooting SSL Errors
CERT_HAS_EXPIRED
CERT_HAS_EXPIRED
Symptoms: Fix: Update your CA certificate file or contact IT.
certificate has expired errors.Diagnosis:UNABLE_TO_VERIFY_LEAF_SIGNATURE
UNABLE_TO_VERIFY_LEAF_SIGNATURE
Symptoms:
unable to verify the first certificate.Cause: Missing intermediate CA certificate.Fix: Ensure your CA file includes the full chain:SELF_SIGNED_CERT_IN_CHAIN
SELF_SIGNED_CERT_IN_CHAIN
Symptoms:
self signed certificate in certificate chain.Fix: Add the self-signed root CA to NODE_EXTRA_CA_CERTS.mDNS Service Discovery
mDNS (Multicast DNS), also known as Bonjour or Zeroconf, enables automatic discovery of OpenCode servers on the local network without manual IP configuration.How mDNS Works
Server publishes service
When
--mdns is enabled, the OpenCode server announces itself on the local network:Clients discover server
mDNS-aware clients (web browsers, mobile apps) query for
_http._tcp.local. services and receive server details.Enable mDNS
Custom Domain Name
http://mycompany-ai.local:4096.
mDNS Implementation
OpenCode uses thebonjour-service library:
Discovery from Clients
mDNS Platform Support
- macOS
- Linux
- Windows
- Docker/Containers
Built-in Bonjour support. Works out of the box.
Security Considerations
Firewall Configuration
Required Ports
Default OpenCode HTTP server port. Customize with
--port.mDNS/Bonjour service discovery. Only needed if
--mdns is enabled.Firewall Rules
Network Architecture Patterns
Pattern 1: Local Development (Default)
- No proxy, no mDNS
- Localhost only
- Fastest, most secure
Pattern 2: Corporate Network with Proxy
HTTPS_PROXYconfiguredNO_PROXY=localhost- Custom CA certificate if proxy intercepts SSL
Pattern 3: Remote Server with mDNS
- Server on dedicated machine
--hostname 0.0.0.0 --mdns- Password authentication required
- Clients auto-discover via mDNS
Pattern 4: Containerized Deployment
- Expose via reverse proxy with SSL
- Internal container networking
- Auth + CORS configured
Best Practices
Always set NO_PROXY
Include
localhost,127.0.0.1 in NO_PROXY when using proxies to prevent TUI connection failures.Use HTTPS proxies
Prefer
HTTPS_PROXY over HTTP_PROXY for encrypted proxy connections.Secure mDNS servers
Always set
OPENCODE_SERVER_PASSWORD when using --mdns or --hostname 0.0.0.0.Test certificates
Verify
NODE_EXTRA_CA_CERTS with openssl s_client before running OpenCode.Next Steps
Server Architecture
Learn about the OpenCode server API and architecture.
Troubleshooting
Diagnose network connectivity issues.
Windows WSL Setup
Optimal network setup for Windows users.