Parasites impact host fitness and constitute an important selective pressure on the host's life history. According to parasite-mediated sexual selection, ornaments are presumed to honestly indicate immune capacity or resistance against parasites, and the chooser sex (typically females) obtains an advantage by selecting more ornamented, thus more immunocompetent mates. Therefore, signalers mounting an immune response must allocate resources from the sexual signal to the immune system, hence reducing the expression of the ornament and becoming less attractive to the choosing sex. Here, we test this idea in the lizard Psammodromus algirus. We inoculated a subsample of males with lipopolysaccharide (LPS) of the cell wall of Escherichia coli, while others served as sham controls. The inoculation of LPS decreased the proportion of ergosterol (pro-vitamin D2) in femoral secretions, and chemosensory tests showed that the scent of LPS-inoculated males was less attractive to females than the scent of control males. Given that ergosterol is a precursor of vitamin D, which has physiological functions as an immune modulator, immunocompromised males likely needed to divert vitamin D to the immune system, reducing the allocation of ergosterol to secretions. In this way, females could detect "sick" males, preferring the apparently healthy males. Overall, our study shows that mounting an immune response is costly in terms of reduced attractiveness. Moreover, we disentangle the underlying mechanism, which involves an honest signal based on vitamin D allocation.