Bankruptcy does not relieve you of all of your debts. It can be complicated, and the law varies from state to state, which is why you need a good bankruptcy lawyer to help you decide if you should file and then represent you throughout the process.
First, you have to be eligible. Usually your income must be lower than average. Often it doesn't matter if you are solvent or not.
Bankruptcy only relieves you of the specific debts listed by your lawyer on the bankruptcy petition. It can relieve you of unsecured debt such as credit card debt. But it does not automatically relieve you of secured debt, which includes taxes owed, your home mortgage, student loans, alimony and child support. If you petition to be relieved of your mortgage debt, the bank has a lien on your property and can take it.
Never increase your secured debt to pay your credits cards, which hurts your finances worse than bankruptcy.
Bankruptcy does not relieve you of debts as a result of your own willful misconduct such as liability from driving while intoxicated or criminal fines and penalties.