If you are still employed and under 59½, you may qualify for a hardship withdrawal to cover an IRS-defined “immediate and heavy financial need.” Qualifying reasons:
Certain medical expenses (you, your spouse, dependents, or beneficiary)
Buying a principal residence (not regular mortgage payments)
Tuition and related fees for the next 12 months of postsecondary education
Preventing eviction or foreclosure on your principal residence
Funeral or burial expenses
Certain repairs to your principal residence, or expenses from a federally declared disaster
You can generally only take out what you need to cover the expense. You sign hardship forms recording your choice and payment details, and your plan administrator approves them.
Taxes: hardship withdrawals are subject to ordinary income tax, and if you are under 59½, a hardship does not on its own waive the 10% early-withdrawal penalty.