Why this is illegal regardless of what you owe
Every state requires a landlord to go through the formal eviction process — notice, then court, then a judge's order — to remove a tenant, and that requirement doesn't have an exception for tenants who are behind on rent or in violation of their lease. A landlord who instead changes the locks, removes a door, or otherwise blocks you from getting into your own home is engaging in what's called a "self-help eviction," and it's against the law regardless of the underlying reason.
What counts as an illegal lockout
Beyond literally changing the locks, this category of illegal conduct generally includes removing a door or window to make the unit unusable, shutting off electricity, water, gas, or another utility to force you out, and removing your belongings from the unit without your consent or a legal process for handling abandoned property. California's Civil Code is a useful concrete example of how comprehensively a state can define this: it separately bars a landlord from willfully interrupting a tenant's utility service and from preventing a tenant's reasonable access by changing locks, removing outside doors or windows, or removing the tenant's belongings, when done with the intent to force the tenant out (Cal. Civ. Code § 789.3).
What it can cost a landlord who does it anyway
Because this conduct is so clearly prohibited, some states attach specific financial penalties to it rather than leaving you to prove ordinary damages alone. California, for example, makes a landlord who violates this law liable for the tenant's actual damages plus up to $100 for each day the violation continues, with a floor of at least $250 for each separate violation, on top of the tenant's attorney's fees (Cal. Civ. Code § 789.3(c), (d)). Other states have their own versions of this kind of penalty built into their landlord-tenant statutes — the exact dollar figures differ, but the underlying prohibition is consistent everywhere.
What to do if it happens to you
Call the police immediately and explain that you've been illegally locked out of your home — officers can often help you get back in that day, since this is treated as an ongoing violation of your right to possession, not just a landlord-tenant paperwork dispute. Document everything: photos of the new lock or blocked entry, a timeline of when you last had access, and any communication with your landlord beforehand. Contact a tenant rights attorney or legal aid organization, since some states let you sue for the kind of statutory damages described above in addition to getting back in.
Harassment short of a full lockout is also often illegal
Some states go further than just banning outright lockouts and separately prohibit a landlord's use of threats or intimidation aimed at pushing a tenant to leave, even without physically blocking entry. California's law, for instance, separately makes it unlawful for a landlord to use force, willful threats, or menacing conduct meant to influence a tenant to vacate (Cal. Civ. Code § 1940.2). If your landlord is pressuring you to leave through threats rather than an outright lockout, that conduct may still be independently illegal in your state.
A concrete example
Say you're two weeks behind on a $1,300 rent payment, and you come home to find your key doesn't work anymore, with a note taped to the door saying to contact the landlord about back rent. That's a self-help eviction regardless of how much you owe — the landlord's only lawful path was a written notice followed by a court filing, not a changed lock. Keep the note, photograph the door, and call the police the same day.
Protecting yourself going forward
Keep a copy of your lease and recent rent receipts somewhere accessible outside your apartment, so you can prove your tenancy even if you're locked out. If you sense a landlord is heading toward this kind of conduct — because of a dispute over rent, repairs, or anything else — document the situation in writing and consider notifying local authorities or a tenant organization before it escalates, rather than only after.