With interest rates climbing yet again, now may be a good time to lock in a new mortgage rate before it becomes even more expensive to borrow. Though refinancing can be a good way to reduce your monthly housing costs, it’s not necessarily the right move for everyone. Here are a few things you should know before you rush to refinance your loan.

1. There’s a cost involved

If refinancing were free, more homeowners would probably do it. But because there are closing costs at play, you’ll need to consider not only whether you can afford the upfront fees, but whether you’ll be staying in your home long enough to recoup whatever money you lay out initially.

The typical homeowner will spend 2% to 5% of his or her loan’s value to refinance, so if you’re looking at a $300,000 loan, that’s anywhere from $6,000 to $15,000 right off the bat. Now, let’s assume that you refinance a similar loan at an initial cost of $10,000, but that doing so lowers your payments by $250 each month. In that case, it will take you 40 months, or close to 3.5 years, just to break even. If you don’t expect to be in your home that long, then it obviously doesn’t pay to refinance. But if you’re planning to stay put for a decade or more, you’ll recoup your closing costs early on and come out way ahead.

Though some lenders claim to offer no-cost refinancing, be aware that what you don’t pay in upfront fees, you’ll pay in the form of a higher interest rate. If you can’t afford those closing costs initially, this may be a reasonable solution, but don’t be fooled into thinking you’re getting off easy.

2. You might raise your lifetime interest payments

As you’re probably aware, a big portion of each mortgage payment you make goes toward your loan’s interest, as opposed to its principal. While refinancing your mortgage might lower your individual monthly payments, it can also increase the amount of interest you pay for your home in your lifetime.

When you refinance a mortgage and don’t change its term (meaning, you go from one 30-year mortgage to another), you’re essentially resetting the clock on your loan. So if you refinance after five years of payments and it takes you another 30 years to pay off your home in full, you’ll wind up making 35 years of payments, as opposed to just 30 — which means you’ll also end up losing more money to interest. Refinancing later in life — meaning, in your 40s or 50s — might also prevent you from paying off your home in time for retirement, and since many seniors bank on that expense going away, carrying mortgage debt could wreak havoc on your budget down the line.

3. Your credit score should play a role in your decision

The goal of refinancing is typically to secure a more favorable interest rate, but if your credit score has gone down since you first got approved for a mortgage, that’s not likely to happen. Just as it’s best to work on boosting your credit before applying for a mortgage, so too should you make certain your credit is decent before attempting to refinance. This includes paying bills on time, limiting the number of credit cards you open, and making sure you’re not using more than 30% of your available credit.

Just how much might your credit impact your interest rate? As an example, if your credit score is 720, you’ll pay close to a full point less in interest than someone whose score is 650. You should only aim to refinance if your credit is as good as or better than it was when you got your initial loan.

Refinancing can work out in your favor under the right circumstances. Just make sure your finances are in order and that you know what you’re getting into before you apply.