livekit/livekit · error
already running
Error message
already running
What it means
LivekitServer.Start is called on a server whose atomic running flag is already true. Start is not idempotent: it guards with s.running.Load() and returns this error instead of registering the node or spawning loops a second time.
Source
Thrown at pkg/service/server.go:216
return
}
func (s *LivekitServer) Node() *livekit.Node {
return s.currentNode.Clone()
}
func (s *LivekitServer) HTTPPort() int {
return int(s.config.Port)
}
func (s *LivekitServer) IsRunning() bool {
return s.running.Load()
}
func (s *LivekitServer) Start() error {
if s.running.Load() {
return errors.New("already running")
}
s.doneChan = make(chan struct{})
if err := s.router.RegisterNode(); err != nil {
return err
}
defer func() {
if err := s.router.UnregisterNode(); err != nil {
logger.Errorw("could not unregister node", err)
}
}()
if err := s.router.Start(); err != nil {
return err
}
if err := s.ioService.Start(); err != nil {
return errView on GitHub (pinned to ee45c3f0b1)
Solutions
- Check server.IsRunning() before calling Start
- Create a new LivekitServer instance instead of re-Starting the existing one
- Ensure only one goroutine calls Start (single supervisor path)
Example fix
// before
server.Start()
// after
if !server.IsRunning() {
if err := server.Start(); err != nil {
log.Fatal(err)
}
} Defensive patterns
Strategy: type-guard
Validate before calling
if server.IsRunning() {
return nil // already started
}
err := server.Start() Type guard
func canStart(s *LivekitServer) bool { return !s.IsRunning() } Prevention
- Make Start single-flight (one goroutine owns the lifecycle)
- Recreate the server instance for restarts instead of calling Start again
- Use IsRunning() as a precondition in wrappers around Start
When it happens
Trigger: Calling Start() twice on the same *LivekitServer instance without waiting for it to shut down (doneChan closed / Stop called). Seen in tests (setupMultiNodeTestWithConfig) or when a supervisor restarts the start routine without recreating the server.
Common situations: Calling Start from both a main goroutine and an init helper; retrying Start after a transient failure elsewhere while the server actually came up; test scaffolding reusing a server object across cases.
Related errors
AI-assisted analysis of livekit/livekit@ee45c3f0b1 (2026-09-02).
Data as JSON: /api/errors/cec0eb2819299d25.
Report an issue: GitHub.