Fix the "Firefox is already running" message by removing leftover lock files.

Firefox Already RunningSep 17, 2016 PDF

Firefox is already running

If you try to open Firefox and get the message “Firefox is already running”, close all Firefox windows and try this script. It removes the leftover lock files:

#!/bin/bash
find ~/.mozilla -name "*lock" -print0 |
while IFS= read -r -d '' file; do
  echo "removing $file..."
  rm "$file"
done

Make sure Firefox is really closed first (pgrep -a firefox shows nothing).

The script only looks in ~/.mozilla. Depending on how Firefox is installed, the profile can also be in:

Firefox fromProfile folder
Snap (Ubuntu default)~/snap/firefox/common/.mozilla
Flatpak~/.var/app/org.mozilla.firefox/.mozilla
Newer versions (XDG)~/.config/mozilla/firefox

Use that folder instead of ~/.mozilla in the find command.