Cefalexin is used to treat a number of infections including: otitis media, streptococcal pharyngitis, bone and joint infections, pneumonia, cellulitis, and urinary tract infections. It may be used to prevent bacterial endocarditis. In addition to being a rational first-line treatment for cellulitis, it is a useful alternative to penicillins in patients with penicillin hypersensitivity. In patients with mild or questionable history of penicillin allergy, cephalasporins are now thought to be relatively safe. Caution should always be taken when prescribing cephalosporins to those with strong history of true penicillin hypersensitivity, however, because cefalexin and other first-generation cephalosporins are known to have a modest cross-allergy in patients with penicillin hypersensitivity.Cefalexin may not be effective against bacteria that incorporate a gene for beta-lactamase on their R-plasmid as the beta-lactam ring is present in the chemical structure of cephalosporin derivatives.