Inc.’s (AMZN) pharmaceutical aspirations may be proving to be more challenging than thought, forcing the company to retreat, lifting the stocks of pharmaceutical companies.

CNBC reported this week that the Seattle, Washington-based e-commerce giant has shelved plans to have its Amazon Business unit, which sells bulk items to companies, sell pharmaceutical products to hospitals, focusing instead on selling medical supplies. The news lifted the fortunes of drug stocks that have been under pressure for months over fears about Amazon’s entrance into the market. It even prompted CVS (CVS) to make a $66 billion offer last year for health insurer Aetna Inc. (AET.) But the stocks traded higher Monday (April 16) after CNBC's report. Shares of Rite Aid (RAD), Walgreens (WAB) and CVS gained more than 6% on the news while Cardinal Health and McKesson increased around 5%. (See more: CVS-Aetna Deal Prompted by Amazon's Drug Moves.)

Amazon’s troubles underscore just how hard it is for it to break into a market that is based on long-term contracts and relationships. According to CNBC, Amazon was having difficulties changing large hospitals' drug purchasing habits. With hospitals already in bed with the likes of Cardinal Health and McKesson, they reportedly balked at overhauling how they purchase pharmaceuticals. On top of that, CNBC reported that Amazon would have to develop a logistics network that could handle the transporting medicines at defined temperatures. (See more: 4 Top Pharmaceutical Stocks for 2018.)

Amazon has long been eyeing the drug and healthcare markets.That has not only pushed pharma stocks down but has led to some companies stepping up their game. In the summer Amazon made its first push into the healthcare market, rolling out a line of private label over-the-counter drugs made by Perrigo (PRGO). Dubbed the Basic Care line, Amazon hawks everything from aspirin to allergy medicine. Its Amazon Business site is focused on medical supplies such as syringes, rubber gloves, and bandages, among other products. And in January Amazon announced it was teaming up with Berkshire Hathaway (BRK.A) and JPMorgan Chase (JPM) to create a new kind of healthcare company.

It's possible that Amazon hasn’t completely ruled out entering the pharmaceutical distribution business. Reports have speculated that the company may choose to sell prescription drugs directly to consumers. Amazon Business could also decide to make a move in that area if its business grows. The online retailer is also eyeing other healthcare products and services and has teams in different departments working on projects including the Alexa team and its Grand Challenge secretive business unit.