Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
FREEDOM251

Freedom251 › Blog › client-server

Can Multiple OpenCode Clients Use the Same Server? Sessions, Access, and Syncing Explained

By Freedom251 Team · · 9 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Yes. One OpenCode server can serve multiple clients. The documented architecture supports a terminal client, browser interface, and programmatic SDK connecting to the same backend. OpenCode’s web documentation specifically says the web interface and an attached terminal can run simultaneously while sharing sessions and state.

That shared state is not the same as guaranteed conflict-free collaboration. The official documentation does not define file locking, prompt arbitration, or what happens when two clients change the same session or files at the same time. Treat one server as a shared control plane, and coordinate concurrent work rather than assuming automatic merge behavior.

As an Amazon Associate I earn from qualifying purchases.

What “multiple clients” means in OpenCode

OpenCode uses a client/server architecture. A server process owns the HTTP API and session resources, while clients provide user interfaces or automation. The server guide describes the terminal user interface (TUI) as a client that talks to a server and says this architecture supports multiple clients and programmatic interaction.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

In practical terms, a single running server can accept connections from:

#1 Best Overall
Dell Optiplex 3060 Desktop Computer | Intel i5-8500 (3.2) | 32GB DDR4 RAM | 1TB SSD Solid State | Built in WiFi | Bluetooth | Windows 11 Professional | Home or Office PC (Renewed)
  • [INTEL POWERED CONTENT] - Built with a 8th Generation Hexa-Core Intel i5 and 32GB of DDR4 RAM; Modern, Windows 11 ready, with 4K support, Executive multitasking, media streaming and smooth, multi-tab web browsing; Perfect as an all-purpose multimedia computer; built for content creators; Plenty of RAM and Mass storage for photo and video editing powered by Intel HD 630
  • [LATEST WIRELESS TECH] - This Dell Desktop Computer easily connects to the internet through the Built In WiFi / Bluetooth
  • [SOLID STATE STORAGE] - This Dell Computer setup comes with an ultra-fast 1TB Solid State Drive (SSD); Setup as the primary boot device; Boot and load programs with lightning speed ; Additional expansion available
  • [BUY & OWN WITH CONFIDENCE] - From the world's largest Microsoft Authorized Refurbisher; Quality Guarantee and Free Tech Support; Award-winning Customer Service; | Support Sustainable Business
  • [MODERN HI-SPEED PORTS] - USB 3.0 (x4) | USB 2.0 (x4) | DisplayPort (x1) | HDMI Port (x1) | Audio Combo Jack (x1) | Audio Out (x1) | RJ-45 Ethernet (x1) | Internal SATA (x3)
  • A terminal attached with the OpenCode CLI.
  • A browser-based web interface.
  • An SDK or other program that calls the server API.
  • Additional terminal or browser clients that have permission to reach the same server.

The clearest documented sharing scenario is a web server with an attached terminal. OpenCode’s web guide states that using both interfaces simultaneously shares the same sessions and state. This means a session created through one of those clients is a server-side resource that the other client can access, subject to authentication and the client’s supported operations.

The documentation does not say that two independent OpenCode servers synchronize with each other. If two machines each run their own server, their sessions should be treated as separate unless you deliberately connect both clients to one common backend.

How the server, clients, and sessions fit together

The server exposes an HTTP API and an OpenAPI specification. Documented operations include listing and creating sessions, retrieving session details, forking sessions, deleting sessions, and sending messages. These operations explain why several clients can work with the same server-side resources: each client is calling the same backend rather than keeping an isolated local copy.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Sharing a session therefore means that clients connected to the same server can see and use that server’s session state. It does not establish a distributed collaboration protocol. The reviewed documentation does not specify a lock, queue, last-write-wins rule, transaction boundary, or merge strategy for simultaneous actions. If two clients send prompts or modify the same files at once, the resulting behavior is not documented and should be considered undefined.

Connection modes at a glance

Client or workflow Typical connection What the documentation confirms Version caveat
Attached terminal opencode attach <url> CLI can attach to a running backend; the web guide confirms shared sessions and state when paired with the web interface. Documented on the standard server, web, and CLI pages.
Web interface opencode web --port 4096 Browser clients can use the web server; an attached terminal can work at the same time against the same sessions. Standard web documentation uses this flow.
Standalone server opencode serve Starts an HTTP server, with documented default port 4096 and loopback host 127.0.0.1. The older server guide says this starts a new server; do not assume it attaches to an already-running TUI.
SDK client createOpencodeClient({ baseUrl: 'http://localhost:4096' }) Programmatic clients can point at an existing server URL; SDK types can be generated from the server’s OpenAPI specification. Use the SDK documentation that matches your installed release.
Current v2 web flow opencode --server <url> or opencode pair Clients can connect to a standalone server, with pairing and shared-service flows documented separately. The v2 API page labels its selected HTTP API surface experimental. Verify commands against your build.

Standard setup: run one server and attach more than one client

The following procedure follows the standard server, web, and CLI documentation. Check the help output of the version installed on your machine before using it on a remote host, because OpenCode also documents a separate v2 connection surface.

1. Start a standalone server

  1. On the host that will own the sessions, run opencode serve.
  2. Unless you change the options, use the documented default of port 4096 and loopback address 127.0.0.1.
  3. Use the server’s --hostname and --port options when you need predictable connection details.

Loopback binding makes the service reachable only from that host. It is the safer starting point for local use. Binding to a network interface is a separate decision that requires authentication and network controls.

2. Attach a terminal client

  1. From a terminal that can reach the server, run opencode attach <url>.
  2. For a local server on the default port, the URL is commonly http://localhost:4096.
  3. If the server requires credentials, supply the username and password options documented by your CLI version.

The attached TUI is a client of the running backend. Starting another local TUI does not automatically mean it is using the first TUI’s process; it must connect to the same server URL.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sale
UGREEN NAS DH2300 2-Bay for Beginners & Personal Users, Phone Backup | AI Album, Private Cloud/Remote Access, File Sharing, Multi-Device Backup, Home Entertainment, 4GB RAM on Board (Diskless)
  • Entry-level NAS Personal Storage:UGREEN NAS DH2300 is your first and best NAS made easy. It is designed for beginners who want a simple, private way to store videos, photos and personal files, which is intuitive for users moving from cloud storage or external drives and move away from scattered date across devices. This entry-level NAS 2-bay perfect for personal entertainment, photo storage, and easy data backup (doesn't support Docker or virtual machines).
  • Set Your Devices Free, Expand Your Digital World: This unified storage hub supports massive capacity up to 64TB.*Storage drives not included. Stop Deleting, Start Storing. You can store 22 million 3MB images, or 2 million 30MB songs, or 43K 1.5GB movies or 67 million 1MB documents! UGREEN NAS is a better way to free up storage across all your devices such as phones, computers, tablets and also does automatic backups across devices regardless of the operating system—Window, iOS, Android or macOS.
  • The Smarter Long-term Way to Store: Unlike cloud storage with recurring monthly fees, a UGREEN NAS enclosure requires only a one-time purchase for long-term use. For example, you only need to pay $459.98 for a NAS, while for cloud storage, you need to pay $719.88 per year, $2,159.64 for 3 years, $3,599.40 for 5 years. You will save $6,738.82 over 10 years with UGREEN NAS! *NAS cost based on DH2300 + 12TB HDD; cloud cost based on 12TB plan (e.g. $59.99/month).
  • Blazing Speed, Minimal Power: Equipped with a high-performance processor, 1GbE port, and 4GB RAM on Board, this NAS handles multiple tasks with ease. File transfers reach up to 125MB/s—a 1GB file takes only 8 seconds. Don't let slow clouds hold you back; they often need over 100 seconds for the same task. The difference is clear.
  • Let AI Better Organize Your Memories: UGREEN NAS uses AI to tag faces, locations, texts, and objects—so you can effortlessly find any photo by searching for who or what's in it in seconds. It also automatically finds and deletes similar or duplicate photo, backs up live photos and allows you to share them with your friends or family with just one tap. Everything stays effortlessly organized, powered by intelligent tagging and recognition.

3. Run the web interface and terminal together

  1. Start the web server with opencode web --port 4096, or use the port selected by your installation.
  2. Open the displayed web address in a browser.
  3. In another terminal, run opencode attach http://localhost:4096.
  4. Open or create a session in either client and confirm that the other client sees the same server-side session list.

This is the scenario for which the official web documentation explicitly promises simultaneous use with shared sessions and state.

4. Connect an SDK client

For an application that should use an existing server rather than start its own process, configure the SDK with the server URL:

import { createOpencodeClient } from '@opencode-ai/sdk'

const client = createOpencodeClient({
  baseUrl: 'http://localhost:4096'
})

The SDK guide also describes generating SDK types from the server’s OpenAPI specification. Keep the generated types and client package aligned with the server release; an API change can break a program even when the URL is reachable.

Using the documented v2 connection surface

OpenCode’s v2 web documentation describes a different connection model. It uses opencode --server <url> for connecting clients to a standalone server and documents opencode pair for a shared service flow. Those commands should not be mixed casually with instructions from the older serve, web, and attach pages.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The v2 documentation describes pairing links that work once and expire after five minutes. It also describes browser or app sessions lasting 30 days and says changing the server password invalidates those sessions. Treat these as v2-specific behavior and verify them in the documentation shipped with the release you installed.

The v2 API reference labels its selected HTTP API surface experimental. That does not negate the documented multi-client design, but it does mean scripts and integrations should be tested after upgrades rather than assuming the same endpoints forever.

What is actually synchronized?

When several clients point to one server, the supported synchronization claim is about server-side sessions and state. A session created in the browser can be available to an attached terminal, and API clients can operate on the same session resources through the server.

Rank #3
Sale
UGREEN NAS DXP2800 2-Bay for Advanced Home Users, Remote Workers & Creators | Home Media & Data Center, Docker & VM, Plex, Fast File Transfer, Intel N100, 8GB DDR5, 2.5GbE, 2x M.2 NVMe, 4K HDMI(Diskless)
  • 【Advanced Home Data & Media Hub】For advanced home users who need phone backup, file storage, and centralized data management. Centralize family photos, 4K videos, movies, computer backups, and personal files in one place while running multiple apps for home entertainment and everyday data management. Suitable for households with growing digital libraries and multiple NAS use cases.
  • 【Built for Creators, Media Servers & Advanced Apps】Powered by the Intel N100 Quad-Core CPU, 8GB DDR5 RAM, 2.5GbE networking, and dual M.2 NVMe slots, DXP2800 handles large files and heavier workloads with ease. Run Docker, virtual machines, and media server applications compatible with Plex—ideal for content creators, tech enthusiasts, and advanced home users managing 4K videos, RAW photos, personal media libraries, and multiple NAS apps.
  • 【Up to 80TB for Growing Digital Libraries】 Supports up to 80TB of storage using two HDD bays and two M.2 NVMe SSD slots for family photos, movies, RAW photos, 4K videos, work files, and device backups. AI photo management supports recognition of people, objects, scenes, and locations, album organization, and duplicate photo detection. HDDs and SSDs are not included.
  • 【AI-powered Home Surveillance】Turn DXP2800 into a centralized home surveillance hub by connecting compatible network cameras and storing recordings locally on your NAS. AI-powered features include Face Recognition, People Detection, and Pet Detection, helping advanced home users review important events more efficiently while managing home surveillance and personal data in one place.
  • 【One data Center Across Your Devices】Keep files from desktops, laptops, phones, tablets, and other devices together instead of scattered across cloud accounts and external drives. Access, back up, organize, and share data across Windows, macOS, Android, iOS, web browsers, and compatible smart TVs—ideal for creators and advanced home users working across multiple devices.

There is no documented separate cloud synchronization service in the reviewed material. The server is the shared authority for the clients connected to it. A client that is offline, connected to a different server, or pointed at a different port will not automatically receive the first server’s sessions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Session sharing also should not be confused with a source-control workflow. The documentation does not promise automatic file synchronization across machines, conflict-free edits, or reconciliation of two prompts that run at once. Use normal source-control branches, file backups, and human coordination when more than one client may alter a working tree.

Concurrent use: what the documentation does not promise

OpenCode documents the ability to use multiple clients, but it does not document concurrency semantics. In particular, the reviewed pages do not explain:

  • Whether a session accepts one prompt at a time or queues simultaneous prompts.
  • Which client’s message is processed first when requests arrive together.
  • Whether file writes are locked, serialized, or allowed to race.
  • How an interrupted request is reported to another client.
  • Whether two clients can safely edit the same file without an external merge process.

For predictable results, assign one client ownership of an active prompt, wait for its operation to finish, and use another client mainly for observation or follow-up. If independent work is required, create separate sessions or forks where appropriate and use your normal version-control review process before combining changes. These are operational precautions, not documented guarantees about OpenCode’s internal conflict handling.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Authentication and network safety

A server reachable only through 127.0.0.1 is not exposed to other machines by default. The risk changes when you bind to a network address such as 0.0.0.0 or place the service on a shared host.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Protect standard server and web modes

  1. Set OPENCODE_SERVER_PASSWORD before starting the server or web service.
  2. The documented default username is opencode; set OPENCODE_SERVER_USERNAME if you need a different one.
  3. Configure the corresponding username and password when attaching a CLI client.
  4. Restrict the listening interface and firewall access to the networks that need it.

The web documentation warns that a server without a password is unsecured. CORS settings control which browser origins may make requests; CORS is not authentication and cannot replace a password or an equivalent access control.

Understand v2 pairing and session credentials

In the v2 flow, pairing links and session cookies provide a different access experience from Basic authentication. Pairing links are documented as single-use and valid for five minutes, while established browser or app sessions are documented as lasting 30 days. Changing the server password invalidates those sessions. Do not assume these rules apply to the standard serve or web commands.

Rank #4
Dell PowerEdge R730xd Server 24B SFF 2U, 2X Intel Xeon E5-2690 v4 2.6Ghz (28-cores Total), 128GB DDR4 RAM, 4X 1.2TB 10K SAS 2.5” 12Gb/s HDD, H730P 2GB RAID, NIC 10Gb + I350 1Gb (Renewed)
  • Dell PowerEdge R730xd 24B SFF 2U Server
  • 2x Intel Xeon E5-2690 v4 2.6Ghz 14-Core (28-cores Total)
  • 128GB DDR4 RAM – 4x 1.2TB 10K SAS 2.5” 12Gb/s
  • Dell H730P mini 2GB 12Gb/s RAID
  • 2x 750W PSU - 2x 10Gb SFP+ 2x 1Gb (RJ45) NIC

Remote access with SSH port forwarding

When a server listens only on a remote host’s localhost interface, OpenCode’s v2 web documentation describes SSH local port forwarding as a way to reach it without binding the service publicly. The general pattern is to create an SSH tunnel from your workstation to the remote host, then point the local client at the forwarded local port.

Use the exact forwarding command and port values shown by the documentation for your release. Confirm that the remote service is listening on its loopback address, protect the SSH account, and avoid exposing an unauthenticated OpenCode endpoint directly to the internet. The v2 documentation also describes a remote-access option with a confirmation prompt; read that prompt carefully because it concerns making the server reachable beyond the local machine.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Troubleshooting multiple-client setups

The second client cannot see sessions

  • Check that both clients use the same scheme, host, and port. localhost on your laptop is not the same machine as localhost inside a remote shell or container.
  • Verify that the first process is the server, not merely a standalone TUI.
  • Confirm credentials and, for browser clients, the configured CORS origin.
  • Make sure the second client is not connected to a different server instance started on another port.

The attach command is rejected

Check the CLI syntax for your installed version. Standard documentation uses opencode attach <url>, while v2 documentation uses opencode --server <url>. Do not substitute one command for the other without checking the matching release notes or built-in help.

The browser connects but requests fail

Check both authentication and CORS. A permitted origin only allows the browser origin to make a request; it does not grant access by itself. Ensure the browser is using the same server URL and that the server password is configured as required by the selected documentation surface.

Two clients produce unexpected edits

Stop issuing simultaneous prompts, inspect the session history and working-tree diff, and recover through your normal source-control or backup process. Because the official documentation does not define conflict resolution, do not assume OpenCode can automatically reconstruct or merge competing file changes.

Which setup should you choose?

Need Recommended documented pattern Important caution
Terminal and browser on one computer opencode web --port 4096 plus opencode attach http://localhost:4096 Use the same server URL so both clients reach the same sessions.
Several local terminal clients Run one opencode serve process and attach each client to it. Coordinate prompts because concurrent behavior is unspecified.
Automation or an internal tool Use the SDK with the existing server’s baseUrl. Keep SDK types and server versions compatible.
Remote server without public exposure Use SSH local port forwarding, following the v2 web instructions where applicable. Secure SSH and keep the OpenCode service bound to the intended interface.
Current v2 shared-service workflow Use opencode pair and the v2 server URL flow. Pairing lifetime, session cookies, and experimental API status are version-specific.

Bottom line for teams

Multiple OpenCode clients can use one server, and the web interface plus an attached terminal are explicitly documented to share sessions and state. SDK clients can also target an already-running server. The safe interpretation is shared access to one backend, not automatic collaborative editing: authentication, network exposure, version-specific commands, and human coordination still determine whether the setup is reliable.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Because the official pages describe more than one command and authentication surface, identify your installed release first. Then follow the matching server, web, CLI, SDK, or v2 documentation instead of combining examples from different generations.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

client-serverDeveloper ToolsOpenCodeRemote AccessSecuritysessions

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.