Jake Boer crossed twice in the second half after Gloucester trailed Castres18-6 after an hour of the contest, but the Cherry and Whites were unable to complete a last-gasp fightback.
The new look line-up, which featured new signings Anthony Allen, Rob Thirlby and Peter Richards, but was without Phil Vickery and Mike Tindall, struggled in the opening two quarters.
The French referee took centre stage with constant breaks in play, and there were six penalties converted in the first half, which ended 12-6 to Castres.
The early pre-season game showed area for development, and after tomorrow's game, two weeks of set-piece work should see more possession being gained in the first warm-up game at Kingsholm, against Calvisano on August 13.
Head coach Dean Ryan said: "It is always disappointing to lose, but there are plenty of positives to take from that 80 minutes.
"It is earlier than usual to be playing, but this tournament will play an important role in our pre-season campaign.
"I am pleased that we scored two tries from line-out ball, and pleased defensively that we did not concede any, especially as Castres had a lot of line-out possession close to our line.
"I was also pleased with the performances from our debutants Rob Thirlby, Peter Richards and Anthony Allen."
Gloucester opened the scoring after three minutes with a Duncan McRae penalty, but Casters levelled 10 minutes later.
McRae then restored Gloucester's lead after 18 minutes, but Casters penalties after 20, 25 and 38 minutes made it 12-6 at the interval.
That lead became 18-6 after 57 minutes with two more Castres penalties, but Boer cut the gap with the first try after 71 minutes.
The Gloucester pack drove 10 metres from a line-out into the Casters 22 and replacement scrum-half Simon Amor spun the ball to Brad Davies.
He combined well with James Simpson-Daniel, before play was brought back for an earlier penalty, which Davies kicked into touch five metres out.
Alex Brown won the line-out and the pack drove over, with Boer emerging with the ball.
Another Castres penalty made it 21-11 after 74 minutes, and Gloucester then threw everything at their French opponents.
Amor earned a penalty in his own half which Davies kicked to touch 10 metres out, and again the pack drove over from the line-out, and again Boer was given the credit.
Davies converted to make it 21-18 with two minutes left, but Gloucester could not find another score, and were set to play the losers of the other semi between Leeds and Clermont-Auvergne tomorrow.
Gloucester: R. Thirlby; M. Foster, J. Simpson-Daniel, A. Allen, M. Garvey (J. Goodridge 54); D. McRae (B. Davies 45), P. Richards (S. Amor 60, A. Hazell 80), N. Wood, O. Azam (J. Parkes 60), G. Powell (T. Sigley 60), P. Buxton, A. Brown, J. Forrester (A. Eustace 45), J. Boer, A. Balding.