At least four people died and the search continued for two more who were missing Thursday after a boat carrying more than two dozen migrants capsized off Panama’s Caribbean coast in an apparent attempt to avoid the treacherous Darien Gap land route.

Panama’s Public Safety Ministry said in a statement Thursday the boat carrying 27 people – mostly Afghans — capsized off the Guna Yala Indigenous area Wednesday. The dead included two women and a child.

NICARAGUA GRANTS ASYLUM TO FORMER PRESIDENT MARTINELLI OF PANAMA

The ministry said that at this time of year, bad weather is often a factor in such accidents, especially involving clandestine migrant smuggling attempts. Video from the government showed the open boat upside down on the rocky coast beside the migrants' bodies.

Panamanian flag

The Panamanian flag flies against a partly cloudy sky in Panama City, Panama, on Tuesday, April 5, 2016. (Susana Gonzalez/Bloomberg via Getty Images)

Crossing the Darien Gap, a jungle-covered land area between Colombia and Panama, used to take a week or more on foot. More established trails and more informal infrastructure supporting migrants have reduced the trek to about three days for many. More than 500,000 migrants crossed the gap last year, more than double the number in the previous year.

But risks remain, including bandits that rob, rape and sometimes kill migrants. Some migrants have turned to the costlier maritime route from Colombia to Panama.

CLICK HERE TO GET THE FOX NEWS APP

Thousands of Afghan refugees entered Brazil last year, and some of those have later struck out to try to reach the United States.