1Panel-dev/1Panel · error
init %s db file failed, err: %v
Error message
init %s db file failed, err: %v
What it means
Error "init %s db file failed, err: %v" thrown in 1Panel-dev/1Panel.
Source
Thrown at core/utils/common/sqlite.go:22
"fmt"
"log"
"os"
"path"
"time"
"github.com/glebarez/sqlite"
"gorm.io/gorm"
"gorm.io/gorm/logger"
)
func LoadDBConnByPath(fullPath, dbName string) *gorm.DB {
if _, err := CreateDirWhenNotExist(true, path.Dir(fullPath)); err != nil {
panic(fmt.Errorf("init db dir failed, err: %v", err))
}
if _, err := os.Stat(fullPath); err != nil {
f, err := os.Create(fullPath)
if err != nil {
panic(fmt.Errorf("init %s db file failed, err: %v", dbName, err))
}
_ = f.Close()
}
db, err := GetDBWithPath(fullPath)
if err != nil {
panic(err)
}
return db
}
func CloseDB(db *gorm.DB) {
sqlDB, err := db.DB()
if err != nil {
return
}
_ = sqlDB.Close()
}View on GitHub (pinned to 5ac7c80881)
Solutions
- Check that the database directory exists and is writable by the 1Panel core process before the db file is created.
- Verify the disk is not full (`df -h`) and the filesystem is not read-only.
- Check file permissions and ownership on the target db file path; remove or fix a broken file with the same name.
- If the path contains a stale directory entry or symlink, remove it and restart the service so the file can be created cleanly.
Example fix
ls -l /opt/1panel/db/ # inspect the path, fix ownership: chown root:root /opt/1panel/db && systemctl restart 1panel
When it happens
Trigger: Thrown at core/utils/common/sqlite.go:22 when the library encounters an invalid state.
Common situations: Occurs when the sqlite database file does not exist and os.Create fails to create it (permission denied, read-only filesystem, or full disk). The process panics. Defense: pre-create the database directory and file with correct ownership, verify write permissions and available disk space, and treat this panic as a fatal environment misconfiguration rather than a transient error.
AI-assisted analysis of 1Panel-dev/1Panel@5ac7c80881 (2026-08-15).
Data as JSON: /api/errors/56c6e08547ba4958.
Report an issue: GitHub.