Two people have died after a listeria outbreak linked to rockmelons in New South Wales, which has so far affected 10 people in three states.

People around the country are being urged not to eat the fruit, particularly if they are pregnant, elderly or have immune system problems.

Affected fruit has been removed from supermarkets, but people may already have listeria-infected rockmelons in their homes purchased at an earlier time.

Authorities have identified cases in six elderly patients in NSW, one in Victoria, and three in Queensland who got sick between January 17 and February 9.

All 10 people consumed rockmelon before their illness.

The contamination is on the fruit's skin, not in the flesh.

Two of the six people in NSW died, but rockmelon has been ruled out as a factor in a third listeria death in that state.

The outbreak has been traced to a farm at Nericon, near Griffith in the Riverina in NSW, while another case has been linked to Victoria.

Cases so far linked to elderly

NSW Health director of communicable diseases Vicki Shepherd said only people with weakened immune systems were at risk.

"If there are levels of listeria on the skin then when you cut it, it can be transferred into the surface where you then eat it," she said.

What is listeriosis? Listeriosis is a serious and sometimes fatal bacterial infection

Listeriosis is a serious and sometimes fatal bacterial infection Symptoms can include fever, headaches, cramps, aches and pains, nausea and diarrhoea

Symptoms can include fever, headaches, cramps, aches and pains, nausea and diarrhoea It can be fatal in newborns, elderly people and people with a weakened immune system

"All the cases linked to this have been elderly people and both the deaths were over 70 years of age.

"Listeria presents usually as a type of septicaemia, so fever, feeling really rotten, often aching at the muscles and it can present some nausea and diarrhoea.

"Vulnerable people should always take a lot of care with cut fruit, so they shouldn't purchase pre-cut fruit of any kind and they should take care with cutting and storing of melons of any type."

On average about 15 people a year die from listeriosis, according to the Australia New Zealand Food Standards Authority.

NSW authorities have withdrawn the affected melons from sale and distribution.

Australian Melon Association industry development manager Dianne Fullelove said other farms had tested negative to listeria and other types of melons were not implicated.