vitessio/vitess · error
deadline exceeded waiting for mysqld socket file to appear:
Error message
deadline exceeded waiting for mysqld socket file to appear:
What it means
Mysqld.wait polls for mysqld's Unix socket file to appear while starting the server. If the caller-provided context expires (deadline or cancellation) before the socket exists, this error is returned, indicating mysqld never became ready. It wraps a startup timeout rather than a connection failure per se.
Source
Thrown at go/vt/mysqlctl/mysqld.go:723
}
}
select {
case <-timer.C:
return fmt.Errorf("timed out after %v waiting for the dba user to have the required permissions", waitTime)
default:
time.Sleep(100 * time.Millisecond)
}
}
}
// wait is the internal version of Wait, that takes credentials.
func (mysqld *Mysqld) wait(ctx context.Context, cnf *Mycnf, params *mysql.ConnParams) error {
log.Info(fmt.Sprintf("Waiting for mysqld socket file (%v) to be ready...", cnf.SocketFile))
for {
select {
case <-ctx.Done():
return errors.New("deadline exceeded waiting for mysqld socket file to appear: " + cnf.SocketFile)
default:
}
_, statErr := os.Stat(cnf.SocketFile)
if statErr == nil {
// Make sure the socket file isn't stale.
conn, connErr := mysql.Connect(ctx, params)
if connErr == nil {
conn.Close()
return nil
}
log.Info(fmt.Sprintf("mysqld socket file exists, but can't connect: %v", connErr))
} else if !os.IsNotExist(statErr) {
return fmt.Errorf("can't stat mysqld socket file: %v", statErr)
}
time.Sleep(1000 * time.Millisecond)
}
}View on GitHub (pinned to 01a25a7d17)
Solutions
- Check mysqld's error log (.err file in the datadir) for the underlying startup failure and fix that first
- Increase the context deadline/budget passed to Wait/Init to allow slow startup on constrained machines
- Verify cnf.SocketFile matches the socket path mysqld is actually configured to create
- Confirm the datadir is initialized, writable, and not already in use by another mysqld instance
Example fix
// before ctx, cancel := context.WithTimeout(ctx, 5*time.Second) err := mysqld.Wait(ctx, cnf) // deadline exceeded // after ctx, cancel := context.WithTimeout(ctx, 60*time.Second) err := mysqld.Wait(ctx, cnf)
Defensive patterns
Strategy: retry
Validate before calling
// pre-check config before starting mysqld
if _, err := os.Stat(cnf.SocketFile); err == nil {
return errors.New("stale socket file present; clean up before starting mysqld")
}
if cnf.SocketFile == "" {
return errors.New("socket file path not configured")
} Try / catch
ctx, cancel := context.WithTimeout(ctx, 60*time.Second)
defer cancel()
if err := mysqld.Wait(ctx, cnf); err != nil {
if strings.Contains(err.Error(), "deadline exceeded waiting for mysqld socket file") {
log.Error("mysqld startup timeout; check error log", slog.Any("error", err))
}
return err
} Prevention
- Give Wait/Init a generous context deadline, especially in CI
- Always inspect the mysqld error log after this timeout — it usually names the real failure
- Confirm socket-file path consistency between my.cnf and the Mysqld config
- Ensure the datadir is initialized and not locked by another instance
When it happens
Trigger: Starting mysqld via Mysqld.Wait or Mysqld.Init with a context whose deadline elapses before mysqld creates its socket file (cnf.SocketFile); mysqld crashing or hanging during startup; wrong socket path in the my.cnf used.
Common situations: mysqld failing to start due to corrupted data dir, bad config, port conflicts, or missing permissions on the datadir; under-provisioned CI runners making startup slower than the context deadline; misconfigured socket-file path so the file never appears where we poll.
Understand the failure class
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- gave up waiting for mysqld to stop
- ReadFile cannot be called on read-write backup
- AddFile cannot be called on read-only backup
- EndBackup cannot be called on read-only backup
- AbortBackup cannot be called on read-only backup
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/7377f8638da5f771.
Report an issue: GitHub.