It's generally a bad idea to invest while you're in debt. Money you owe continues to compound interest costs against you, and failure to pay most debts could result in bankruptcy and/or the loss of your possessions to debt collectors. In addition, while investing offers you the opportunity for positive returns, there are no guarantees that any investment will work out either in the short term or the long run.

Despite that general rule, there are still a small handful of situations where investing while you have debt may very well be a reasonable approach to take. Doing so does add risk versus waiting until you're completely debt-free to invest. Under the right set of circumstances, though, it can help you get an early start on your financial plan to enable you to retire comfortably.

Worried couple working through their finances.

Image source: Getty Images.

What has to be true to make it even remotely feasible?

There are a few key factors that you need to consider when determining whether a debt is OK to have while you're investing. First, consider the interest rate on the debt, both any current interest rates and any future interest rates you may face with the debt. If the interest rate you currently face or would face after a teaser period ends is close to or higher than you can reasonably expect to earn on your investments, pay off that debt before investing.

Over the long haul, the stock market has returned around 9.5% annualized. Given the risks and volatility involved in investing compared to the sure thing associated with debt payback, think long and hard about investing while carrying any debt with an interest rate above 6% or so. If you're planning to invest in bonds, your relevant potential return and comparison rate will most likely be even lower due to low current interest rates.

Second, consider the cash flow you have to come up with every month to service that debt. Regardless of the interest rates you're paying, you have to cover your basic costs of living as well as your debt service costs before you should even think about investing. If you ever find yourself running out of money before you run out of month, you need cut costs out of your debt service or your lifestyle (or both), even if all your debts are at 0% interest.

Third, think about what would happen if you faced a financial emergency while still in debt, such as the loss of your job or a serious medical issue. While you could tap money you've invested to cover some or all of the costs you'll face, nearly all investments with reasonably high rates of return these days carry no guarantees they'll retain value.

Having to sell your investments at a loss to cover an unexpected expense increases the net impact of that expense compared with covering it from your cash flow. As a result, you'll probably want at least a basic emergency fund of savings set aside before you start investing, to help mitigate that risk.

What debts can be OK?

Money balanced against time.

Image source: Getty Images.

Many people -- myself included -- invest while carrying a mortgage. With low interest rates, the potential federal tax deductibility of interest payments, and a monthly price tag that's frequently less than renting the equivalent property, it can be reasonable to consider investing while keeping that debt. It depends heavily on the terms of your mortgage, however. If you have a high interest rate or a balloon payment, you'll most likely want to get the mortgage paid off first.

Likewise, depending on the terms of your student loans, it may be a reasonable choice to start investing before you completely pay those off. Particularly if your interest rates are low enough and you're eligible to deduct your student loan interest, those loans may become candidates.

In addition, same-as-cash financing deals and ultra-low interest rate car loans could potentially be debt to keep while you're investing. Just be sure you're really getting the best total price on whatever it is you're buying, as many of those "deals" hide the interest rate in the form of an inflated purchase price. 

If you do choose to keep debts while investing, remember that your potential returns from investing are not guaranteed and that you still have to cover your debt payments. The consequences of not paying your debts can include things like foreclosure on your house, repossession of your car, or even seeing your Social Security check garnished to cover your student loan costs.

Two places to prioritize your investments

401(k) egg inside a trophy, with coins around the base.

Image source: Getty Images.

If you weigh the risks and impacts versus the potential rewards and decide you're willing and able to hold some debt while investing, there are two investment vehicles you should consider prioritizing. The first is your employer-sponsored retirement plan, such as a 401(k) or 403(b). If you get a match from your employer for contributing, this is typically the best place to start your long-term investing as that match puts more money to work, compounding on your behalf quicker.

The second is your Roth IRA, if you're eligible to make direct contributions to one. After you've maxed out your employer-sponsored match, the Roth IRA has two key features that make it a great place to invest for the long haul. First, the money can potentially grow tax free for your retirement. Second, should you need to pull money out of the Roth IRA early, you can withdraw your direct contributions at any time for any reason with absolutely no tax or penalty on those withdrawals.

Balance your risks and potential rewards to make the right choice for you

It's not easy to choose between completely paying off your debts before investing and investing while carrying some properly structured debt. To make an informed decision for yourself, balance the risks associated with those debts with the potential rewards you can get from starting your long-term investing plan that much sooner.

By making a well-informed decision based on those factors along with your personal risk tolerance level, you can improve your chances of building an end-to-end financial plan that works for you.