Coffee can be difficult to remove due to the natural tannin dye. There are three methods commonly used.
A home remedy is to apply vinegar and blot with a white towel. Diluting a carpet acidic rinse liquid 1:5 works on most easy spots. Commercial coffee stain removers are normally effective on difficult or pre-cleaned spills. However, the active ingredient, sodium metabisulfite, can bite your nose and is considered hazardous to breathe.
One way to permanently set a coffee stain is to use a high-pH cleaner, so if the spot has been repeatedly cleaned, you may be out of luck.