Europe's toughened borders are prompting migrants to switch focus to the United States, but their trek is being thwarted in Central America, where a bottleneck has formed, according to the International Organization for Migration.
In Costa Rica, a makeshift camp has sprung up housing hundreds of Africans and Haitians. Elsewhere in the country smaller numbers of Afghans and Pakistanis are biding their time to head north.
They are being stalled by Nicaragua, which strictly closed its border eight months ago to migrants without visas, mainly to stop the flow of thousands of US-bound Cubans through its territory.
But that closed-door policy has also trapped what are called "extra-continental" migrants -- those coming from outside Latin America.
There are an estimated 2,000 such migrants in Costa Rica.
Their number has increased since March, since the EU did a deal with Turkey to send back migrants trying to reach Europe through Greece and eastern European states built barriers across their borders.
"We have documented cases of people telling us they chose this route to the United States or Canada because they felt that getting to Europe was too dangerous, that it was too difficult to enter Europe or the conditions in Europe weren't what they hoped for," said the IOM's representative in Costa Rica, Roeland de Wilde.
"Most of them seem to be coming through from Brazil and other South American countries that are facing declining economic situations."
The Pakistanis and Afghans, accounting for around 10 percent of the migrants, are well-organized and often lay up in basic hotels, de Wilde said.
Most of the ones saying they are from Africa are making do with plastic sheets strung up as shelter by the roadside.
- Haitians pretending to be Africans -
Not all of the latter are "extra-continental," although many pretend to be.
"More than half" the migrants presenting themselves as Africans are from Haiti, an impoverished Caribbean country with a predominantly black population that speaks French, de Wilde said.
"They say they are Congolese, but when questioned they don't know from which part of Congo they come from," he said.
"Sometimes they say Kinshasa or Brazzaville, mixing up one Congo for the other. When asked which ethnicity they belong to, they have no idea."
The Democratic Republic of Congo, whose capital is Kinshasa, and the Republic of Congo, ruled from Brazzaville, are neighbors in central Africa.
While both use French, the former is riven by deadly ethnic violence in its east, increasing the odds of emigrants from there receiving asylum.
In northern Costa Rica close to the border with Nicaragua, near the town of Penas Blancas, African and Haitian migrants try to get by in rudimentary conditions while hoping they will be allowed to continue north to America.
"We can't stay here. No human being can live in these conditions," complained Alin Treme, a 31-year-old who said he was from Congo.
"It rains every day, we're always in mud, the water pours into the tents and we sleep soaked," he said, speaking a mix of Portuguese, French and Spanish.
Near him, a man cut garlic under the burning sun, preparing an improvised soup for his wife and one-year-old son.
Trash from the camp piled up not far away, raising a cloud of stink, flies and mosquitos in the tropical air.
"Our destiny isn't in Costa Rica or Nicaragua or Honduras. Why won't they let us pass?" asked Wilson Joseph, a migrant who said he was from French-speaking Senegal though he spoke Spanish with an accent from the Dominican Republic, Haiti's neighbor.
- Brazil's downturn -
When questioned by AFP, many in the camp claiming to come from the Democratic Republic of Congo or Senegal were unable to give precise details about those countries. They often communicated in languages and accents suggesting they were Haitians trying to hide their nationality.
Most said they had worked in Brazil for several years, but decided to leave when that country's economy dived into recession.
"When I arrived in Brazil, it was great: there was a lot of work in 2011, 2012 and 2013. Things got difficult in 2014, the economy got worse, and in 2016 I could no longer support my wife and my kid," said Eddie Miche, a 27-year-old wearing the blue-and-red of Haiti's flag though he said he was from Congo.
Miche's lot was better than the others. He was staying in a shelter set up by the Costa Rican government in community centers and sports halls. But there was not enough room to accommodate all the migrants.
In any case, all were determined to find a way to get through the closed borders, to America.
Some have turned to people-smugglers, known as "coyotes," who promised passage for more than $1,000.
Wilson Joseph was one who paid.
"I paid a coyote $1,200 who took me to San Juan (a town in southern Nicaragua). He left me in a house and said 'I'll come back later today or tomorrow.'
"After three days he didn't return and I went out into the street, where the police saw me and arrested me and threw me back into Costa Rica," he said.
Meanwhile, the backlog keeps growing.
Mauricio Boraschi, the head of Costa Rica's prosecutorial unit fighting illegal migrant people-smuggling, said he had reports of more groups heading up from Brazil, Colombia and Panama.
"This isn't going to stop just like that," he told Costa Rica's Radio Columbia in an interview.