Ofgem has told energy firms to hand back more than £400m they hold from closed accounts to former customers.

The watchdog has said it "expects suppliers to do more" to return the cash, having found they held at least £202m from around 3.5 million former domestic customers and £204m from 300,000 business accounts.

The regulator, which looked into balances held by the companies and the handling of closed accounts, concluded there was "an unacceptably large amount of money being retained rather than returned to consumers".

Ofgem is also examining whether suppliers' current policies and practices are fully compliant with existing rules, including those requiring firms to treat consumers fairly.

Customers needed to be confident they would not lose out if they closed an account with their present supplier, it said.

The big six energy companies have all raised prices in recent months

It expected suppliers to do all they could to return money to individual consumers, and to tell consumers clearly what to do when closing an account.

Where they were unable to do so, it said suppliers should find ways to use the money to benefit consumers more widely and to clearly explain their plans.

The big six energy companies are already under pressure having all raised prices in recent months.

The consumer group Which? said it was "shocking" some firms were sitting on millions of pounds of customers' cash.

Most major suppliers recently committed to automatically refund surpluses to current direct debit customers, following pressure from the regulator.

Ofgem 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 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."

The regulator advised consumers who had switched to another company or changed address to contact their former supplier.

Those about to switch supplier were urged to take a meter reading just before doing so and to give a forwarding address to the company they were leaving.

A spokesman for Energy UK, the trade association for the energy industry, said suppliers tried to ensure customers' money gets back to them but claimed firms were owed far more in unpaid debts.

He said: "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."