Skip to main content

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:
Names help you identify instances when listing them:
Output:

Advanced Configuration

Specifying Exact Ports

For consistent access (especially useful for bookmarks and remote access), specify exact ports:
If you specify a port that’s already in use, Portal will fail to start. Use openportal list to see which ports are currently occupied.

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

Shows all active instances with their configuration.

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:
This removes entries for processes that are no longer running.

Remote Access for Multiple Instances

Via Tailscale VPN

When accessing multiple instances remotely via Tailscale:
Create mobile bookmarks for each instance with descriptive names:

Using Nginx Reverse Proxy

For cleaner URLs, set up Nginx to route by subdomain or path:

Subdomain-based routing

Path-based routing

Enable and reload:

Persistent Multi-Instance Setup

Using systemd Services

Create separate systemd services for each project:
Enable and start all services:

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:
Or with Docker (see next section).

Docker Multi-Instance Setup

Run instances in isolated containers:
Start all instances:

Best Practices

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
Maintain a port allocation document:
  • 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
OpenCode sessions are stored in:
Each instance shares this directory. To separate instances completely, use different user accounts or Docker containers.

Troubleshooting

Error: Port 3000 is already in useSolutions:
  1. Check what’s using the port:
  2. Use a different port:
  3. Stop the conflicting process:
Issue: Started instance but it doesn’t appear in openportal listDebug:
  1. Check if process is running:
  2. Clean stale entries:
  3. Check registry file:
Symptoms: Server becomes slow with many instancesSolutions:
  1. Check resource usage:
  2. Limit number of concurrent instances
  3. Increase server RAM
  4. Use resource limits (systemd or Docker)
  5. Stop unused instances:
Issue: Sessions appearing in wrong instanceExplanation: All instances share the same OpenCode sessions directory.Workarounds:
  1. Use clear session naming: [project-name] feature description
  2. Run instances as different users
  3. Use Docker with separate volumes
  4. Delete sessions from the correct instance context

Next Steps