It's a scenario that's happened to the best of us: You're at a restaurant, the bill comes, and you generously whip out your credit card to treat your fellow diners to a fabulous lunch. Only moments later, the server comes back and sheepishly informs you that your card has, in fact, been declined.

Now there are a number of reasons why something like that might happen. If you're in a new city and your credit card company suspects fraud, for example, it might decline such a charge in an effort to protect you. But here's another explanation: You've maxed out your credit card limit, and therefore have no one to blame for your embarrassing predicament but yourself.

Man handing a credit card to a woman at a restarant

IMAGE SOURCE: GETTY IMAGES.

It's estimated that 26 million Americans had at least one credit or debit card declined over the past year, and the most common reasons were insufficient funds in the case of the latter, or having maxed out one's credit limit in the case of the former. All told, 12% of credit and debit card users were stuck in the sort of uncomfortable situation detailed above, according to data from CompareCards.com. Suspicion of fraud, by contrast, was the second-most cited reason for having credit or debit cards get rejected.

If you've ever had one of your cards declined, you no doubt know how awkward it can be. So if you'd rather not have that experience again, here's what you need to do.

1. Be aware of your credit limit or account balance

Do you know how much you're allowed to charge on your credit card at once? Many consumers don't. But if you don't commit that number to memory, and check your balance against it regularly, you'll risk charging too much and having your card rejected.

Similarly, you should always be aware of how much money you have available in your debit account. Logging on and checking that balance a few times a week could spare you the embarrassment of having that debit card declined.

2. Always have a backup

Charging the bulk of your expenses on a single card can make your bills easier to manage. But because you never know when you might run into trouble with that primary card, it always pays to have a backup payment option in your wallet. This could be another credit card, a blank check, or good old cash. Either way, you'll have an additional means of paying a bill on the spot if your go-to card doesn't work.

3. Get overdraft protection

Imagine being able to keep using your debit card even once you've depleted your account balance. It's possible if you purchase overdraft protection. Banks offer this service so consumers get a little leeway in situations like the one detailed above. The downside, of course, is that it comes at a fee, but it may be worth the peace of mind.

4. Prevent erroneous fraud alerts

Though most instances of credit or debit card rejection come as a result of account mismanagement, fraud, as we learned, is often to blame as well. But here's the thing: Often, you'll have a card rejected simply because your bank or credit card company suspects fraud, not because criminal activity is actually happening on your account. To avoid this, tell your bank or credit card company if you're traveling in a different part of the country or overseas, or if you're planning a purchase outside the norm. For example, if you buy a $1,000 appliance, and the bulk of your purchases are $40 or less, your card issuer might decline the transactions to protect you, thereby inadvertently causing you a hassle. But if know you'll be making that purchase and inform your credit card company ahead of time, you shouldn't run into a problem.

Having a credit or debit card rejected is never fun, but in most cases, it's actually avoidable. Follow these simple steps, and with any luck, you'll never have it happen to you again.