sqlmapproject/sqlmap · error · SqlmapFilePathException

unable to flush the session file

Error message

unable to flush the session file ('%s')

What it means

--flush-session asked sqlmap to delete the hash/session SQLite file, but os.remove raised an OSError (typically the file is locked by another sqlmap process or permissions forbid deletion); the stale session cannot be discarded.

Solutions

  1. Close other sqlmap instances using the same session file
  2. Fix write permissions on the output directory
  3. Delete the session file manually and rerun
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at lib/core/target.py:499 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of sqlmapproject/sqlmap@0a35b20e39 (2026-08-26). Data as JSON: /api/errors/9721f4dcd4ab7d96. Report an issue: GitHub.

Appendix: source

Thrown at lib/core/target.py:499

def _setHashDB():
    """
    Check and set the HashDB SQLite file for query resume functionality.
    """

    if not conf.hashDBFile:
        conf.hashDBFile = conf.sessionFile or os.path.join(conf.outputPath, SESSION_SQLITE_FILE)

    if conf.flushSession:
        if os.path.exists(conf.hashDBFile):
            if conf.hashDB:
                conf.hashDB.closeAll()

            try:
                os.remove(conf.hashDBFile)
                logger.info("flushing session file")
            except OSError as ex:
                errMsg = "unable to flush the session file ('%s')" % getSafeExString(ex)
                raise SqlmapFilePathException(errMsg)

        for suffix in ("-shm", "-wal"):
            leftover = conf.hashDBFile + suffix
            if os.path.exists(leftover):
                try:
                    os.remove(leftover)
                except OSError:
                    pass

    conf.hashDB = HashDB(conf.hashDBFile)

def _resumeHashDBValues():
    """
    Resume stored data values from HashDB
    """

    kb.absFilePaths = hashDBRetrieve(HASHDB_KEYS.KB_ABS_FILE_PATHS, True) or kb.absFilePaths
    kb.brute.tables = hashDBRetrieve(HASHDB_KEYS.KB_BRUTE_TABLES, True) or kb.brute.tables

View on GitHub (pinned to 0a35b20e39)