You can file for bankruptcy if a creditor is already suing you. The automatic stay of Chapter 7 bankruptcy stops almost all collection actions, including lawsuits.  When the bankruptcy petition is filed, any legal action brought against you must  cease.