Overview
OpenCode Portal supports running multiple instances simultaneously, allowing you to work on different projects without conflicts. Each instance can have its own:- Dedicated ports (Web UI and OpenCode server)
- Separate sessions and chat history
- Independent working directory
- Custom instance name
Why Multiple Instances?
Project Isolation
Keep different codebases completely separate with their own AI context and sessions.
Client Work
Maintain distinct instances for different clients, preventing context mixing.
Environment Separation
Run separate instances for development, staging, and production environments.
Team Collaboration
Share different instances with different team members based on project access.
Basic Multi-Instance Usage
Starting Multiple Instances
The simplest way to run multiple instances is to use different directories:OpenCode Portal automatically finds available ports if the defaults (3000 and 4000) are already in use.
Using Custom Names
Give each instance a memorable name:Advanced Configuration
Specifying Exact Ports
For consistent access (especially useful for bookmarks and remote access), specify exact ports:Port Organization Strategy
Organize ports systematically for easier management:Running from Different Directories
You can start Portal from anywhere and specify the project directory:Managing Instances
List All Running Instances
Stop Specific Instance
Stop instances by name or port:The
stop command gracefully shuts down both the Web UI and OpenCode server for the specified instance.Clean Up Stale Entries
If processes were killed ungracefully, clean up stale registry entries:Remote Access for Multiple Instances
Via Tailscale VPN
When accessing multiple instances remotely via Tailscale:Using Nginx Reverse Proxy
For cleaner URLs, set up Nginx to route by subdomain or path:Subdomain-based routing
Path-based routing
Persistent Multi-Instance Setup
Using systemd Services
Create separate systemd services for each project:Using tmux for Multiple Sessions
Organize multiple instances in tmux windows:Using PM2 Process Manager
PM2 provides excellent process management with monitoring:Resource Management
Monitoring Resource Usage
Resource Limits
If running many instances on limited resources:Docker Multi-Instance Setup
Run instances in isolated containers:Best Practices
Naming Conventions
Naming Conventions
Use consistent, descriptive names:
- Include project name:
client-acme-frontend - Include environment:
api-staging,api-production - Keep it short but meaningful:
docs,admin-panel - Avoid special characters: use hyphens, not spaces or underscores
Port Allocation
Port Allocation
Maintain a port allocation document:
Session Organization
Session Organization
- Use clear session names within each instance
- Delete old sessions regularly to avoid clutter
- Keep sessions focused on specific features or bugs
- Document session purposes in the first message
Backup and Migration
Backup and Migration
OpenCode sessions are stored in:Each instance shares this directory. To separate instances completely, use different user accounts or Docker containers.
Troubleshooting
Port conflicts
Port conflicts
Error:
Port 3000 is already in useSolutions:-
Check what’s using the port:
-
Use a different port:
-
Stop the conflicting process:
Can't find instance in list
Can't find instance in list
Issue: Started instance but it doesn’t appear in
openportal listDebug:-
Check if process is running:
-
Clean stale entries:
-
Check registry file:
High memory usage with multiple instances
High memory usage with multiple instances
Symptoms: Server becomes slow with many instancesSolutions:
-
Check resource usage:
- Limit number of concurrent instances
- Increase server RAM
- Use resource limits (systemd or Docker)
-
Stop unused instances:
Instances mixing up sessions
Instances mixing up sessions
Issue: Sessions appearing in wrong instanceExplanation: All instances share the same OpenCode sessions directory.Workarounds:
- Use clear session naming:
[project-name] feature description - Run instances as different users
- Use Docker with separate volumes
- Delete sessions from the correct instance context
Next Steps
- Mobile access guide for accessing multiple instances remotely
- Tailscale setup for secure VPN access
- Troubleshooting guide for more common issues