It’s important to be aware, however, that even though a current refinance rate may be lower than the rate on your existing mortgage, current refinance rates tend to be higher than current purchase rates. Also, one type of refinance loan is more expensive than the other. We’ll help you sort out why some refinances are more expensive, and—more importantly—what you can do to lower the cost.

How Mortgage Rates Are Determined

No matter what type of mortgage you’re getting—a purchase mortgage or a refinance—there are common factors that affect the rates you’re offered. Here are some of the factors lenders consider.

Risk Level

One of the biggest factors that goes into how much your loan will cost is how risky lenders see you as a borrower. This can be measured in a lot of different ways, but two of the main things lenders want to know are your credit score and how much debt you already have. The better your credit score, the less risky you are as a borrower and the better the rates you’ll be offered, regardless of whether it’s a purchase mortgage or a refinance. The more debt you have, especially relative to your income, the riskier you are as a borrower as well. In fact, lenders set hard debt-to-income limits for most mortgages and if you carry too much debt, you may be denied outright for a loan.

Loan Amount

Another factor that affects your risk level is how much you’re borrowing. Larger loans—especially relative to how much your house is worth—are riskier for the lender to make and for you to pay off, so they may have higher interest rates. That’s why you hear the advice so often to save up as much for a down payment as you can. Paying more for your home upfront offloads some of that risk from the lender, so you’ll be rewarded with better rates and fees. In fact, many mortgages tack on an additional charge for private mortgage insurance (PMI) each month if your down payment is less than 20%.

Loan Term

The longer you have a loan out, the greater the risk that you won’t be able to pay it back. You may be laid off in a future economic downturn, for example, or become disabled. That’s why 15-year mortgages usually carry lower interest rates than 30-year mortgages.

Lenders May See Refinances as Riskier and Less Desirable

When it comes to mortgage refinances, there are two types. Depending on which type of refinance you’re doing, you may pay a lot more for it, said Deb Klein, a branch manager with Primary Residential Mortgage in Chandler, Arizona. Rate-and-term refinances swap out your current mortgage for a new one, usually with a lower rate and/or a different term length. But even if you keep the same term length, your refinance rate may be higher than the going mortgage rate. There are a few reasons for that, said Richard Martin, director of real estate lending solutions with Curinos, a data company for financial services providers that supplies mortgage rate information to The Balance for publishing. “Most lenders tend to prioritize purchase transactions over refinances, as they tend to have tighter closing deadlines” and purchase loans are more likely to close than refinance loans, Martin said in response to emailed questions. Both of these can help speed business along. Cash-out refinances, on the other hand, replace your loan with a new, larger one. In return, you get the difference back as cash between what you currently owe and what your new, higher loan amount is for. People do this for a lot of reasons, such as consolidating high-interest debt, paying for a child’s college education, or paying for home repairs. In any case, you’re taking out a larger loan than you had before. “In the eyes of the lender, this is one of many reasons why cash-out refinances are considered riskier than a rate-and-term refinance,” said Klein. As a result, the interest rates on cash-out refinance loans tend to be higher than rate-and-term refinance loans.

Refinancing May Come With Extra Costs and Fees

Besides the difference in interest rates, refinancing comes with other costs you should be aware of. You had to pay a lot of different closing costs when you took out your mortgage the first time. Now that you’re thinking about replacing it, you’ll need to pay many of those same fees all over again, such as appraisal fees, origination fees, and credit report fees. In fact, the average refinance costs around $5,000 in closing fees, according to Freddie Mac. It’s a good idea to ask about the fees involved while you’re shopping around for rates. Two lenders might offer the same rate, for example, but one might charge more fees than the other one. The only way to know is to ask.

How To Shop for the Best Refinance Rates

Whether you’re going with a rate-and-term refi or a cash-out refi, there are certain things you can do to make sure you’re getting the best refinance rates currently available. Start with your current lender and ask if they can give you a quote on a refinance loan. Take that quote around to different lenders and compare the rates and fees. Check with as many lenders as you can from a range of financial institutions such as online lenders, banks, and credit unions. Make sure you get all of your rate-shopping done within two weeks so it’s recorded as a single hard credit inquiry on your report, which will limit the impact on your credit score. Want to read more content like this? Sign up for The Balance’s newsletter for daily insights, analysis, and financial tips, all delivered straight to your inbox every morning!