Yes, there are costs involved. There is a filing fee for new cases, a fee to get copies, and fees for witnessess and mileage, for instance. To see the current fees and other court costs, see the court's fee schedule.
Rule 11 of the Federal Rules of Civil Procedure prohibits filing lawsuits that are clearly frivolous or filed merely to harass an individual. If after reviewing your complaint, the court determines that you have filed a lawsuit for an improper or clearly unnecessary purpose, it may impose sanctions against you, including ordering you to pay a fine to the court or pay the legal fees of the person or persons against whom you filed the lawsuit. In certain types of cases, such as employment discrimination cases, if you lose, you may be required to pay the legal fees of the winning party. In all cases, if you lose, you may be required to pay some of the costs the winning party incurred in the course of the lawsuit.