Britain's biggest energy firms have been told by the regulator Ofgem to refund former customers more than?400 million held in closed accounts.
Consumer groups said it was "shocking" that the "Big Six" gas and electricity suppliers had kept such large sums and urged them to return the money as possible.
Energy Minister Greg Barker said the scale of the amounts involved was "astonishing".
Between them the Big Six companies - British Gas, EDF Energy, E.On, npower, ScottishPower and SSE - are holding at least ?202 million from around 3.5 million former household customers, Ofgem found.
The energy firms have also retained ?204 million from 300,000 closed business accounts.
The regulator said it had found "an unacceptably large" amount of money being retained rather than returned to customers, and a wide variation in company practices.
Ofgem's interim chief executive, Andrew Wright, said: "When many people are struggling to make ends meet, it is vital that energy companies do the right thing and do all they can to return this money and restore consumer trust.
"We want to see decisive action by suppliers, individually and collectively, to address this issue and, wherever possible, to ensure that the balances they currently hold are returned to consumers.
"Where this can't be done, any remaining sums should be used to benefit consumers more generally, and suppliers need to be very clear with consumers about what they will be doing with this money."
Mr Barker welcomed the regulator's announcement but added: "The scale of credit held in closed energy accounts that Ofgem has uncovered is astonishing, and I want to go further to ensure that, where possible, customers are rightly returned the money that is theirs."
Energy firms said they always refunded the money in closed accounts wherever possible and added that they were owed much larger sums by former customers who had not paid their bills.
But consumer groups said the companies should make more efforts to return the cash.
Citizens Advice chief executive Gillian Guy said: "It's appalling that firms have been sitting on hundreds of millions of pounds of customers' money, making little effort to return it.
"Hard-pressed households who are struggling to get by and businesses feeling the pressure on their finances would benefit from the money being in their pockets, not their energy company's bank account.
"Suppliers do not hold the purse strings of households in this country. If they have people's money, they should return it as soon as possible."
Richard Lloyd, executive director of consumer group Which?, added: "If true, it's shocking that some of the biggest energy companies are sitting on millions of pounds worth of consumers' cash.
"Suppliers must return this money as soon as possible and be clear about what customers need to do when they close accounts."
Comparison websites said many families have been forced to make the choice between "heating and eating" amid rounds of inflation-busting hikes to their bills.
Clare Francis, editor-in-chief of MoneySuperMarket, said: "It's little surprise that there is so little trust in the industry when things like this come to light.
"Before an individual can close an energy account and move to a new provider, they must pay off any money they owe to their existing provider, yet shockingly providers haven't necessarily been doing the same thing if they owe the customer money.
"It is therefore good news to see the regulator clamping down on this practice and calling on energy firms to return any money they have retained from former customers."
A spokesman for industry body Energy UK said: "Although companies are working to return money where there are credit balances, sometimes former domestic customers provide no new contact details so suppliers don't know how, or to whom, they can return the money.
"The most common reasons energy companies end up holding funds are when the bill payer has moved home or when a customer dies and suppliers have no record of the next of kin.
"Suppliers already agreed with ministers last year that they would take all reasonable steps to trace customers who leave a credit balance behind."
He added: "If you think you may be owed money, get in touch with your supplier past and present, to check if they have funds to return to you."
British Gas director Ian Peters said his company went "well beyond" its legal obligations to seek out customers owed money and had provided refunds to 10,000 people since 2012.
But he added: "Any credit owed to customers is significantly outweighed by the value of customer debt. At September 2013, the amount owed to household customers was ?40 million, with customer debt five times that amount, at almost ?200 million."
SSE said it took "all reasonable steps" to find customers and return their credit balances, and added that the bad debt it has written off in recent years is about four times the amount of credit it has not refunded.
Ofgem's announcement follows recent commitments by most major suppliers to automatically refund surpluses to current direct debit customers.