Britain's parliament was hit by a cyber attack on Saturday in which hackers tried to access email accounts, just over a month after a ransomware worm crippled parts of the country's health service.

Chris Rennard, a member of the Liberal Democrat party in the upper House of Lords, was the first to draw attention to the problem, using Twitter to announce: "Cyber security attack on Westminster, Parliamentary emails may not work remotely, Text urgent messages."

A spokeswoman for the House of Commons confirmed that unauthorised attempts had been made to access parliamentary accounts and that systems were in place to protect member and staff details.

"Parliament has robust measures in place to protect all of our accounts and systems, and we are taking the necessary steps to protect and secure our network," the spokeswoman said.

"As a precaution we have temporarily restricted remote access to the network. As a result, some Members of Parliament and staff cannot access their email accounts outside of Westminster."

Britain's National Health Service was hit by a massive ransomware worm in May which crippled the computer system and forced some hospitals to turn away patients and divert ambulances.

Liam Fox, the minister for international trade, said the attack was not a surprise and should act as a warning to Britons.

"We've seen reports in the last few days of even cabinet ministers' passwords being for sale online," he told broadcasters.

"We know that our public services are attacked so it's not at all surprising that there should be an attempt to hack into parliamentary emails."

Part of the GCHQ spy agency, the National Cyber Security centre was set up in October last year to tackle what the government believes is one of the biggest threats to British security.