– Zhang Zhejun used a fat plastic straw to gently tap the pale yellow pharmaceutical powder onto a piece of silver foil that lay on an electronic scale. He made sure the amount was just right before he poured it into a clear capsule.

When making cancer drugs at home, the measurements must be precise.

Zhang had no medical experience and no background in making drugs professionally. He did this out of desperation. His mother suffered from lung cancer and required expensive drugs that China’s ambitious but troubled health care system couldn’t provide.

He was aware of the risks. The drug he was making had not been approved by regulators in China or the United States. Zhang had bought the raw ingredients online, but he was not sure from whom, or whether they were even real. “We’re not picky. We don’t have the right to choose,” he said. “You just hope the sellers have a conscience.”

It is a desperation born of necessity. China’s aging population is increasingly stricken with deadly diseases like cancer and diabetes, but many cannot find or afford drugs.

The country’s rudimentary insurance system does not begin to cover the ever-rising prices of treatments and drugs. Coverage also depends on where somebody lives, and some rural residents still lack access to certain drugs.

Despite a costly new safety net from the government, illness remains the leading reason Chinese families fall below the poverty line, according to official figures.

Many of China’s problems are self-inflicted. Major bureaucratic hurdles keep lifesaving drugs out of the reach of millions who need them. Drug approvals remain dauntingly backlogged.

To stay alive, many sick people in China — and the people who love them — break the law. Online marketplaces are filled with illegal pharmaceuticals. Dealers run underground pharmacies. In some cases, cancer patients and their families make the drugs themselves, finding the ingredients and the instructions online.

China’s challenges are playing out globally. Lower prices send Americans to Canada and Mexico looking for the medicines they need. Patients from Russia to Britain desperately hunt for drugs through online “buyers’ clubs” — networks that scour the world for cheaper generic medicines.

In China, the public has become increasingly concerned about access to drugs, putting pressure on the leadership.

Last year, police raided Hong Ruping’s modest apartment in southwestern China. Under a television, they found what they were looking for: medicine to treat chronic kidney disease. Hong, who is unemployed and has kidney dialysis three times a week, explained that the cheap knockoff drugs were for him.

The officers seized the drugs, warning that they were not approved by the country’s regulators. Then, the officers let him go.

Some health experts are torn about encouraging the use of drugs that are not approved. “I find it hard to give a one-size-fits-all view on whether they should or shouldn’t do it,” said Gordon Liu, director of Peking University’s China Center for Health Economic Research and an adviser to the government.

“Some generics from India are likely to offer newer treatments than the existing medicines in the mainland,” Liu said. He added: “You’re acquiring drugs through informal channels. Not only are you taking on economic risks, but also the uncertainty of the technology.”

Dr. Shen Lin, director of digestive oncology at the Peking University Cancer Hospital, said several of her patients on long-term medication could not afford the drugs anymore, and had asked whether they could use generics from India. She has tried to dissuade them, saying she could not vouch for drugs from unofficial sources. Still, she said, “if they continue on their path, they would go bankrupt.”