Because Social Security by itself won't provide income to pay for retirement, we all need to save independently to ensure we're able to stay afloat during our golden years. That's why workers are generally urged to contribute aggressively to whatever tax-advantaged retirement plan they have at their disposal, whether it's an IRA or a 401(k).

The benefit of funding the traditional type of either account is getting an up-front tax break in addition to a solid opportunity to amass wealth. Currently, contributions to traditional IRAs and 401(k)s are made with pre-tax dollars, and once funded, those accounts get to grow on a tax-deferred basis until withdrawals are taken.

The flip side of that arrangement, however, is that withdrawing funds from either account before age 59 1/2 could result in a 10% penalty, not to mention taxes on the amount removed (though to be fair, those taxes would apply in retirement as well). That's why when working folks need money, they're often advised to take out a retirement-plan loan rather than an early withdrawal.

Man in shirt and tie fanning out bills

Image source: Getty Images.

Unfortunately, new data from J.P. Morgan Asset Management tells us that a growing number of middle-income earners are embracing this option. A recent study found that 28% of them borrowed 20% of their account balances in 2018. And while that might be preferable to taking early withdrawals, it's a problem nonetheless.

The dangers of borrowing from a retirement plan

Many people tap their nest eggs when they find themselves desperate for money before being eligible for penalty-free withdrawals. The problem is that in doing so, they risk landing in a financially sticky situation.

First, let's talk about 401(k) loans. Many plans will allow you to borrow up to the lesser of $50,000 or 50% of the amount you have vested in your plan, though some plans will let you borrow up to $10,000 even if that's more than 50% of your vested balance. You will, however, be on the hook for interest on that loan, and you'll usually need to repay it within five years. Technically, you're paying that interest to yourself, not a bank. But if you don't repay that loan on time, it will be treated as an early withdrawal, at which point you'll be subject to the 10% penalty we talked about earlier.

And if you lose your job after having taken out a 401(k) loan, you'll generally get only 90 days to repay your outstanding balance. If you don't meet the deadline, that 10% early withdrawal penalty will come into play.

Also, regardless of how much you borrow, usually, you're barred from making new contributions to your 401(k) while you're in the process of repaying a plan loan. That means losing the associated tax break as well.

If you're housing your retirement savings in an IRA, you can't take out a loan in a traditional sense. But you can borrow money on a short-term basis via a rollover.

Rollovers occur when you transfer funds from one retirement plan to another. You can do a direct rollover, where those funds are deposited into your new account, or an indirect rollover, where you get a check for those funds and are responsible for rolling them into a new qualified account within 60 days. If you exceed that 60-day threshold, you'll face that 10% early withdrawal penalty.

But if your need for money is truly temporary, a rollover might work. And if you manage to repay your retirement plan within 60 days, you won't lose out on all that much growth on your money. Still, it's a risky prospect because you only get that narrow window to make your IRA whole again.

When you're sitting on a pile of money for retirement, it's natural to think of tapping those funds if a need for cash arises. But think twice before you do, because you could wind up facing penalties and other restrictions that hurt you. A much better bet is to build emergency savings so that you have immediate access to cash when you need it.

The Motley Fool has a disclosure policy.