coder/code-server · error · Error
Cannot open socket paths
Error message
Cannot open socket paths
What it means
Thrown by the open() helper in src/node/util.ts when it receives a plain string instead of a URL object. The function intentionally rejects strings because in code-server a string address is assumed to be a Unix socket path, which cannot be opened by a browser/xdg-open/cmd. The fix is to pass a URL instance so new URL(address) succeeds.
Source
Thrown at src/node/util.ts:428
if (platform === "win32" || platform === "wsl") {
command = platform === "wsl" ? "cmd.exe" : "cmd"
args.push("/c", "start", '""', "/b")
urlSearch = urlSearch.replace(/&/g, "^&")
}
return {
args,
command,
urlSearch,
}
}
/**
* Try opening an address using whatever the system has set for opening URLs.
*/
export const open = async (address: URL | string): Promise<void> => {
if (typeof address === "string") {
throw new Error("Cannot open socket paths")
}
// Web sockets do not seem to work if browsing with 0.0.0.0.
const url = new URL(address)
if (url.hostname === "0.0.0.0") {
url.hostname = "localhost"
}
const platform = (await isWsl(process.platform, os.release(), "/proc/version")) ? "wsl" : process.platform
const { command, args, urlSearch } = constructOpenOptions(platform, url.search)
url.search = urlSearch
const proc = cp.spawn(command, [...args, url.toString()], {})
await new Promise<void>((resolve, reject) => {
proc.on("error", reject)
proc.on("close", (code) => {
return code !== 0 ? reject(new Error(`Failed to open with code ${code}`)) : resolve()
})
})
}
View on GitHub (pinned to 51f90a376b)
Solutions
- Pass a URL object to open(): open(new URL('http://localhost:8080')).
- If you intended to use a socket path, do not call open() on it — disable the auto-open-browser behavior (set --open=false / do not pass --open).
- Separate the listen address (which may be a socket) from the browser-open address (which must be an http(s) URL).
- Check the caller that constructs the address and ensure it builds a URL when opening is desired.
Example fix
// before
open(serverAddress) // serverAddress is a socket-path string
// after
open(new URL(`http://localhost:${port}`)) Defensive patterns
Strategy: type-guard
Validate before calling
// Only call open() with a real http(s) URL.
import { open } from '../util'
if (address instanceof URL && /^https?:$/.test(address.protocol)) {
await open(address)
} Type guard
function isOpenableUrl(addr: unknown): addr is URL {
return addr instanceof URL && /^https?:$/.test(addr.protocol)
} Try / catch
try {
await open(maybeAddress)
} catch (e) {
if (e.message === 'Cannot open socket paths') {
// address was a socket-path string; skip auto-open
} else throw e
} Prevention
- Never pass socket-path strings to open().
- Construct a URL from the configured host/port before opening.
- Disable --open when running with --socket.
- Keep the listen-address type distinct from the open-browser address type.
When it happens
Trigger: Calling open(someString) where someString is a socket path (e.g. '/run/code-server/socket') rather than an http(s) URL. This is the 'open in browser' code path used after server start; passing a socket-path string is treated as a programming error.
Common situations: A code path that resolved the listen address to a socket path string and forwarded it to open(); a refactor that changed the address type from URL to string; misconfigured --socket / SOCKET_PATH combined with the auto-open-browser feature.
Related errors
- --idle-timeout-seconds must be greater than 60 seconds.
- No opened code-server instances found to handle ${paths[0]}
- Unsupported auth type ${req.args.auth}
- Missing password
- Invalid port
AI-assisted analysis of coder/code-server@51f90a376b (2026-08-12).
Data as JSON: /api/errors/ea65ef83c33d4d81.
Report an issue: GitHub.