Financial experts are constantly urging workers to prioritize their IRAs and 401(k)s. And there's a reason for that.

Once you retire, Social Security might take the place of about 40% of your previous paycheck, assuming you're an average earner and that benefits aren't cut broadly. But most retirees need more like 70% to 80% of their former wages -- sometimes more -- to cover their expenses and maintain a decent standard of living. So it's important to having savings on top of those monthly benefits.

A person using a laptop.

Image source: Getty Images.

To that end, the sooner you start contributing money to an IRA or 401(k) plan, the more opportunity that money has to grow. So it's a great idea to begin funding a retirement account in your 20s, or whenever you first start collecting a steady paycheck.

That said, contributing to an IRA or 401(k) doesn't always make sense. And in one situation, it's actually best to not fund one of these retirement accounts and put your money elsewhere.

Your emergency fund has to come first

It's very necessary to sock money away for retirement. But it's also extremely important to have money on hand for emergency situations or unplanned expenses. Those could run the gamut from losing your job to needing a home or car repair your regular paycheck can't cover.

Without an emergency fund, you risk racking up very expensive debt to cope with an unplanned expense or period of unemployment. And that could lead to many years of financial struggle.

Now you might assume that if you're in a bind, you can just tap your IRA or 401(k) to address the issue at hand. But you should know that even if you're able to take a hardship withdrawal from your retirement account, that won't necessarily get you out of paying the 10% penalty that comes with taking a distribution before age 59 and 1/2.

So if you don't have an emergency fund at all, then you actually shouldn't contribute money to an IRA or 401(k) until you've built up some near-term cash reserves. You need money that's accessible to you immediately in case life throws you a curve ball.

How much emergency savings should you have?

There's no single rule when it comes to building an emergency fund. And the amount you choose to save may depend on your circumstances.

If you're single in a month-to-month lease with no dependents, you may feel comfortable having a three-month emergency fund. If you're married with two children and a mortgage, you may want a six- to nine-month emergency fund. And if you work in a niche role or industry where there aren't a lot of jobs, you may want to save enough to cover a full year of bills.

You may also decide to maintain two emergency funds -- one to replace your paycheck in the event of job loss, and another to cover home or car repairs, which could happen at the same time you end up unemployed. For example, you may decide to keep a six-month emergency fund in one account, and a separate $5,000 in a different account to specifically address a car or home repair.

Focus on the near term first

It's certainly a great thing to fund an IRA or 401(k) plan consistently. And the more time you give that money to grow, the better.

But before you focus too heavily on addressing your long-term financial needs in retirement, you need to make sure your near-term needs are being met. That means having a fully loaded emergency fund -- whatever your definition of that happens to be. So if you don't have a complete emergency fund, or you have no emergency savings at all, it actually makes sense to put IRA or 401(k) contributions on pause until that changes.