chenhg5/cc-connect · error
another cc-connect instance is already running (PID %d) with
Error message
another cc-connect instance is already running (PID %d) with config %s
What it means
Windows variant of lock contention: syscall.CreateFile on the lock file failed and readPIDFromLockFile recovered a positive PID, so this error names the running instance's PID and config path. CreateFile fails when another instance holds the lock with no share/write access, or on permission problems — but the intent of the message is "another instance is running".
Source
Thrown at cmd/cc-connect/instance_lock_windows.go:52
pathPtr, err := syscall.UTF16PtrFromString(lockPath)
if err != nil {
return nil, fmt.Errorf("cannot convert lock path: %w", err)
}
handle, createErr := syscall.CreateFile(
pathPtr,
syscall.GENERIC_READ|syscall.GENERIC_WRITE,
syscall.FILE_SHARE_READ,
nil,
syscall.OPEN_ALWAYS,
syscall.FILE_ATTRIBUTE_NORMAL,
0,
)
if createErr != nil {
pid := readPIDFromLockFile(lockPath)
if pid > 0 {
return nil, fmt.Errorf("another cc-connect instance is already running (PID %d) with config %s", pid, configPath)
}
return nil, fmt.Errorf("another cc-connect instance is already running with config %s", configPath)
}
pid := os.Getpid()
syscall.SetFilePointer(handle, 0, nil, syscall.FILE_BEGIN)
syscall.SetEndOfFile(handle)
var written uint32
syscall.WriteFile(handle, []byte(fmt.Sprintf("%d\n", pid)), &written, nil)
syscall.FlushFileBuffers(handle)
return &InstanceLock{
handle: handle,
path: lockPath,
acquired: true,
}, nil
}
View on GitHub (pinned to 4000b2338a)
Solutions
- Confirm the PID is live (tasklist /FI "PID eq <PID>") and stop the existing instance (taskkill /PID <PID> or stop the service).
- Use a different --config path if a genuinely independent instance is required.
- If the PID is stale, delete the lock file and retry.
Defensive patterns
Strategy: try-catch
Try / catch
lock, err := AcquireInstanceLock(configPath)
if err != nil {
var pid int
if _, scanErr := fmt.Sscanf(err.Error(), "another cc-connect instance is already running (PID %d)", &pid); scanErr == nil {
fmt.Fprintf(os.Stderr, "stop PID %d first.\n", pid)
}
os.Exit(1)
} Prevention
- Run instances via Windows services or scheduled tasks that enforce singletons.
- Always use the same user account for the daemon.
- Use distinct config paths for parallel instances.
When it happens
Trigger: AcquireInstanceLock on Windows while another cc-connect process holds an open handle (created without FILE_SHARE_WRITE) on <configDir>\. <configBase>.lock and its PID was read back successfully.
Common situations: Second launch while the service/scheduled-task instance is running; running under a different user while the first instance's handle denies sharing.
Related errors
- another cc-connect instance is already running (PID %d) with
- another cc-connect instance is already running with config %
- another cc-connect instance is already running with config %
- %s
- taskkill failed: %w: %s; process kill fallback failed: %w
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/bdef8c3879cd01a0.
Report an issue: GitHub.