After overcharging thousands of residential gas customers, National Grid has agreed to refund more than $1.5 million to them, according to Attorney General Maura Healey.

Healey negotiated an agreement with National Grid in which it will issue credits on the gas bills of more than 4,500 customers who were incorrectly charged a nonheating rate, rather than the less expensive heating rate. 

Because residents who heat their homes with gas generally use more gas than those residents who only use gas for cooking or other nonheating purposes, the rate for heating gas is less expensive. 

“As the ratepayer advocate for Massachusetts, we want to ensure that utilities are not overcharging their customers,” Healey said in a news release. “With this agreement, thousands of customers who paid too much for their gas usage will receive the credit they deserve, and National Grid will take additional measures to help prevent this in the future.”    

The credit amounts will be customer-specific and issued later this year.

The company will establish a way to confirm with new customers whether they'll be using gas for heating or not and will work to conduct periodic reviews of customer data to confirm they are getting the correct rate.

Amie O'Hearn, a spokeswoman for National Grid, said that the company uncovered the situation during a routine review of residential natural gas accounts last year. National Grid will roll out the new processes in the coming weeks.

"We apologize for the mistake and any inconvenience this may have caused," she said. "As customers self-report whether they use gas for heating or nonheating purposes, this was a valuable lesson to us that we need to strengthen our internal processes and amp up our customer education in this area."