We all make our share of money-related mistakes in life. For some of us, that means buying too large or expensive a home. For others, it means passing up a promotion and the salary boost that comes with it. But a new TD Ameritrade survey finds that millennials consider not having an emergency fund to be their primary financial blunder. 

You need money in the bank

Why is having an emergency fund so important? It's simple: Without one, you risk racking up loads of credit card debt, or struggling financially in other ways, the minute an unplanned expense lands in your lap.

Imagine you wake up one morning in the dead of winter to find that your heating system no longer works. That's not a repair you can put off, but if it costs $2,000 and you don't have that money sitting in savings, you'll have no choice but to borrow it, and generally in the form of charging it to a credit card. Once that happens, you'll be subject to whatever exorbitant interest rate your credit card company charges on outstanding balances, which will cost you extra money and make that debt more difficult to pay off.

Man sitting at a table, holding his head and looking down at a binder.

IMAGE SOURCE: GETTY IMAGES.

A better bet, therefore, is to have a healthy chunk of savings in the bank at all times. This way, you won't have to panic or stress when your car breaks down, you get slapped with a costly medical bill, or you lose your job and can't find another one right away.

How much should you save for emergencies?

As a general rule, your emergency fund should contain enough money to pay for three to six months of essential living expenses. You don't necessarily want to have much more than that in a savings account, because if you do, you'll lose the option to invest your cash for added growth. (Remember, your emergency fund shouldn't be invested; it should stay in the bank at all times, where your principal is protected. But even a high-yield savings account today pays peanuts compared to the sort of return you might see with stock investments.) On the other hand, you do want to aim for that three-month threshold at the very least so that you're covered not just for major bills, but for a potentially prolonged period without an income.

Building your emergency fund

Coming up with three to six months' worth of living expenses is no easy feat. But a good way to start is to set up a budget and see what you're currently spending money on. From there, you'll be able to identify places to cut corners and free up cash for savings.

For example, imagine you currently spend $200 a month on takeout food. You may not realize you're spending that much until you actually comb through your bills and add that line item to your budget, but once you see that it's there, you can choose to slash that expense in half and bank the difference.

Another good way to build emergency savings? Get yourself a second job. Putting in just a few hours a week on top of your main job could help you establish that safety net sooner. And that side gig doesn't have to be something you hate. You can walk dogs on weekends, sell homemade crafts online, or even moonlight as a personal chef.

The longer you go without an emergency fund, the more you put your finances at risk. If you're without three to six months of living expenses in the bank, make that your first priority -- before the next unexpected bill pops up.