MHSanaei/3x-ui · error
source sqlite not found at %s: %w
Error message
source sqlite not found at %s: %w
What it means
MigrateData (SQLite → PostgreSQL) stats srcPath up front and wraps the failure: the configured SQLite source file does not exist. This is the same guard DumpSQLiteToBytes uses, applied to the migration entrypoint, so the copy never starts with a missing source. Typically a wrong path in the migrate-db invocation.
Source
Thrown at internal/database/migrate_data.go:69
&model.ClientExternalLink{},
&model.ClientGroup{},
&model.InboundFallback{},
&model.Host{},
&model.NodeClientTraffic{},
&model.NodeClientIp{},
&model.ClientGlobalTraffic{},
&model.OutboundSubscription{},
}
}
// MigrateData copies every row from the configured SQLite file at srcPath into
// a fresh PostgreSQL database described by dstDSN. The destination tables are
// (re)created with AutoMigrate; truncate and copy then run in one transaction,
// so a failed migration leaves the destination data unchanged. Source data is
// left untouched.
func MigrateData(srcPath, dstDSN string) error {
if _, err := os.Stat(srcPath); err != nil {
return fmt.Errorf("source sqlite not found at %s: %w", srcPath, err)
}
if dstDSN == "" {
return errors.New("destination DSN is required")
}
if err := os.MkdirAll(path.Dir(srcPath), 0o755); err != nil {
return err
}
srcDSN := srcPath + "?_journal_mode=WAL&_busy_timeout=10000"
src, err := gorm.Open(sqlite.Open(srcDSN), &gorm.Config{Logger: logger.Discard})
if err != nil {
return fmt.Errorf("open sqlite source: %w", err)
}
srcSQL, err := src.DB()
if err != nil {
return err
}View on GitHub (pinned to ad32144c42)
Solutions
- Locate the real DB (default /etc/x-ui/x-ui.db; check the panel's data dir) and pass its absolute path.
- If migrating from another server, copy the x-ui.db over first, then run migrate.
- Confirm the path is visible inside the container/mount namespace when running in Docker.
Defensive patterns
Strategy: validation
Validate before calling
if _, err := os.Stat(srcPath); err != nil {
return fmt.Errorf("copy the panel DB first (default /etc/x-ui/x-ui.db): %w", err)
} Prevention
- Run `x-ui migrate-db` on the host/container that actually holds x-ui.db, with the absolute path.
- Copy the old server's DB over before starting a SQLite→Postgres migration.
When it happens
Trigger: Running `x-ui migrate-db` (or MigrateData) with srcPath pointing somewhere other than the real x-ui.db; running on a host where the panel stores its DB elsewhere (different install prefix, Windows layout); path typo.
Common situations: Migration prep on a fresh box before copying the old DB over; Docker volume mounted at a different path than assumed; container exec with wrong workdir-relative path.
Related errors
- copy %T: %w
- sqlite backup is unavailable for PostgreSQL
- destination DSN is required
- traffic writer queue full
- open sqlite source: %w
AI-assisted analysis of MHSanaei/3x-ui@ad32144c42 (2026-08-15).
Data as JSON: /api/errors/88f873374141474d.
Report an issue: GitHub.