When you're short on money or faced with an overwhelming, unexpected expense, the money in your retirement savings accounts can start looking mighty tempting. That's probably why the Transamerica Center Retirement Survey found that 27% of workers had taken either a loan or an early withdrawal from their 401(k) plans. If you're in that 27%, you've kneecapped your retirement dreams -- but you still may be able to set things right. First, though, you need to understand the consequences of a 401(k) loan or early withdrawal.

The problem with 401(k) loans

In principle, a 401(k) loan sounds like a pretty good deal: You're essentially borrowing from yourself, so the money just ends up going back into your retirement savings account. No harm, no foul, right? Not exactly.

There are some major drawbacks to taking a 401(k) loan. First, while the money does eventually go back into your 401(k), as long as it's not in the account it's not earning returns. That means your accounts won't be growing as fast as your retirement plans expected, so you could end up significantly short on hitting your retirement goals even if you repay every penny you borrowed.

Second, once you take the money out, you may find it difficult to put it all back. Failing to repay your 401(k) loan results in some nasty tax penalties. If you default on the loan, then the part you haven't repaid is treated as an early withdrawal. That means you'll have to pay income taxes and a 10% early withdrawal penalty on all that money when you do your tax return for the year. Different 401(k) plans will have different rules regarding exactly when you're considered in default, so check with your HR representative to find out what the rules are for your own plan.

Third, if you leave your employer while still repaying your loan, the entire outstanding balance will be due immediately. If you don't have the money to repay the whole thing, then guess what -- you'll be in default on the loan and will get hit with the aforementioned tax bills. Since whether or not you keep your job isn't always in your control, this adds a definite element of risk to any 401(k) loan.

Cash in envelope labelled 401k

Image source: Getty Images.

What to do if you've tapped your 401(k)

If you've taken money from your 401(k), either as a loan or as an early withdrawal, the first thing to do is to immediately revise your retirement plan. Sit down with a retirement calculator using your new account balance and current contribution schedule, and see if you'll still have enough saved by your planned retirement date to meet your needs. If not, you'll need to increase your contributions until you do have enough.

For example, let's say that your goal is to have $1 million in your 401(k) by the time you retire at age 67. You're currently 40 years old and after having taken a hardship withdrawal, you have a balance of $80,000 in your 401(k) account. Assuming a 7% average annual return, the calculator will tell you that you'll need to contribute $6,310 per year (which comes to about $526 per month) to hit your retirement savings goals.

You may not be able to meet your new contribution requirement, in which case you have a few options. First, you can delay your retirement. In the above example, if you decided to retire at age 70 instead of age 67, you'd only need to contribute $3,869 per year (about $322 per month) to have $1 million in your retirement savings accounts by your new retirement date. Second, you can reduce your other expenses to free up some extra money for retirement contributions. And third, you can find a way to increase your income -- ask for a raise, switch to a higher paying job, take on a part-time job temporarily, or so on.

When it comes to retirement savings, speed is of the essence. Even if you can't immediately hit your new contribution goal, at least increase your current contributions by a few dollars a month. Thanks to the miracle of compound interest, even a minor increase in contributions now can end up making a significant difference in your final balance. It might not entirely repair your depleted 401(k) balance, but at least it will reduce the negative consequences from a 401(k) loan.