DAR ES SALAAM (Reuters) - The United States has warned its citizens in Tanzania to be cautious after the commercial capital Dar es Salaam announced a crackdown on homosexuality, a criminal offense in the country.

FILE PHOTO - A general picture shows the skyline of Tanzania's port cty of Dar es Salaam, July 12, 2013. REUTERS/Andrew Emmanuel

In an alert on its website late on Saturday, the U.S. Embassy in Tanzania advised Americans to review their social media profiles and internet footprints.

“Remove or protect images and language that may run afoul of Tanzanian laws regarding homosexual practices and explicit sexual activity,” it said.

The alert said any U.S. citizen who was detained or arrested should ensure the Tanzanian authorities informed the embassy.

Dar es Salaam’s administrative chief Paul Makonda said on Wednesday that a special committee would seek to identify and punish homosexuals, prostitutes and online fraudsters in the city from this week.

The foreign ministry said Makonda was voicing his own opinion and the planned crackdown did not have national government support.

“The government of the United Republic of Tanzania would like to clarify that those are his own views and not the government position,” the ministry said in a statement.

Last October, at least 12 men were arrested at a Dar es Salaam hotel in a raid on a gathering which authorities said was to promote same-sex relationships.

President John Magufuli has cracked down on homosexuality since winning power in 2015, and a conviction for having “carnal knowledge of any person against the order of nature” could lead to a sentence of up to 30 years in jail.

Homosexuality remains taboo across much of Africa and gay people face discrimination or persecution, with rights groups often reluctant to speak publicly in defense of gay rights.

In 2016, Tanzania banned non-governmental organizations from distributing free lubricants to gays as part of efforts to control the spread of HIV/AIDS, even though some health experts warn that shutting down such outreach programs could put the wider population at higher risk of infection.