Search the internet, and you'll see tons of advice highlighting the importance of retirement savings. And it's all valid. Without savings, you'll risk struggling financially during your senior years.

Social Security pays the average senior today only about $18,000 a year. That's hardly enough to live comfortably. In fact, those benefits will generally replace around 40% of the typical worker's pre-retirement earnings, and most seniors need about twice that much income to maintain a decent lifestyle.

So it pays to contribute to an IRA or 401(k) from as early an age as possible. The more time you give yourself to grow wealth in one of these accounts, the more successful you're likely to be.

The words 'emergency fund' on a table next to various denominations of bills.

Image source: Getty Images.

But believe it or not, there's one financial circumstance under which saving in a retirement plan is not the right move: when you don't have emergency savings.

An estimated 39% of Americans don't have the funds on hand to cover an unplanned $400 expense, says the Federal Reserve Board, when in reality, we're all supposed to have enough money in cash to pay for three to six months of essential living expenses. If your emergency fund isn't complete, then that's the first place you should divert your extra money -- even if that means putting retirement savings on hold.

Why emergency savings trump retirement savings

Having money in an IRA or 401(k) will help you cover your bills when you're older, but it won't help you in the near term when an unplanned expense pops up. If you take an early withdrawal from a retirement account, you'll face a 10% penalty on the withdrawal, a pretty substantial loss.

But money in a savings account can be accessed at any time and for any reason, without losing a portion of it in the process. And you can generally withdraw funds from savings on the spot; with a retirement plan, it could take time for that money to make its way to you.

And without emergency savings, you'll risk racking up credit card debt when unexpected expenses rear their ugly heads. Not only can this cost you money in interest, but it can also hurt your credit score, making it difficult to borrow affordably in the future.

That's why you should aim to save enough money to cover three to six months of essential bills before focusing on retirement savings. Though it's noble to want to fund your nest egg, and it's smart to take advantage of the tax savings associated with retirement accounts, if you don't have emergency savings, you'll risk a host of unhealthy financial consequences.

So cut back on spending, get a second job, or do whatever else it takes to build some cash reserves. Once you're done, you can begin contributing regularly to an IRA or 401(k) to secure your financial future.