Canadian heavy crude prices rallied Friday as U.S. refinery demand rises and increased volumes are shipped by rail car.

Heavy Western Canadian Select’s discount to West Texas Intermediate futures narrowed to $39.25 a barrel, the smallest since late September, data compiled by Bloomberg show. The absolute price increased to $17.43 a barrel after dropping on Thursday to the lowest in Bloomberg data stretching back a decade.

BP Plc returned its crude unit and a coker to operation after maintenance was completed, a person familiar with operations said Wednesday. At the same time, increased volumes of crude are being exported by rail as companies sign up for multi-year contracts.

Crude-by-rail loadings at monitored terminals in Western Canada reached a record-high monthly average of 274,000 barrels a day in October, according to Genscape Inc. data. Canadian oil companies have said they seek to double those volumes by next year.

“If rail volumes continue expanding, it could help cover for limited storage space and help producers avoid cuts,” Dylan White, oil market analyst at Genscape Inc. said in an email.

A glut caused by a surge Western Canadian production running into limited pipeline capacity this year has caused heavy and light grades to trade at record discounts to world oil benchmarks. Last month, WCS more than $50 a barrel to WTI. A year ago, the discount was less than $15.

The price collapse has prompted oil sands producers including Cenovus Energy Inc. and Canadian Natural Resources Ltd. to shut what could amount to 140,000 barrels a day or more this quarter.

Crude inventories at five monitored terminals in Western Canada reached 34.2 million barrels the week ended Nov. 9, Genscape’s White said. That’s an increase of about a million barrels versus two weeks earlier. Inventories reached the highest observed capacity in May 2014.