A ban on travel by U.S. passport holders to North Korea will take effect on Sept. 1 and Americans in the country should leave before that date, the U.S. State Department said on Wednesday.

Journalists and humanitarian workers may apply for exceptions to the ban, the department said in a public notice.

The U.S. government last month said it would bar Americans from travelling to North Korea due to the risk of "long-term detention" there.

The ban comes at a time of heightened tensions between the United States and North Korea, which has been working to develop a nuclear-tipped missile capable of hitting the United States.

North Korea will become the only country to which Americans are banned from travelling.

American student Otto Warmbier, sentenced last year to 15 years' hard labour in North Korea, returned to the United States in a coma on June 13 after being released on humanitarian grounds, and died June 19. The circumstances surrounding his death are not clear, including why he fell into a coma.

North Korea has said through its state media that Warmbier's death was "a mystery" and dismissed accusations that he had died as a result of torture and beating in captivity.

The State Department issued a notice in the Federal Register on Wednesday declaring U.S. passports invalid for travel to, in or through North Korea. The restriction takes effect in 30 days, and applies for one year unless extended or revoked by the secretary of state.

"Persons currently in North Korea on a U.S. passport should depart North Korea before the travel restriction enters into effect on Friday, September 1, 2017," the department said in a statement.

Professional reporters or journalists, representatives of the International Committee of the Red Cross or the American Red Cross travelling on official missions, those travelling to North Korea for "compelling humanitarian considerations" and those whose requests are "in the national interest" may ask for a special validation of their passports in order to travel to the country, the State Department said.

North Korea is currently holding two Korean-American academics and a missionary, a Canadian pastor and three South Korean nationals who were doing missionary work. Japan says North Korea has also detained at least several dozen of its nationals.