Autophagy defends the mammalian cytosol against bacterial infection. Efficient pathogen engulfment is mediated by cargo-selecting autophagy adaptors that rely on unidentified pattern-recognition or danger receptors to label invading pathogens as autophagy cargo, typically by polyubiquitin coating. Here we show in human cells that galectin 8 (also known as LGALS8), a cytosolic lectin, is a danger receptor that restricts Salmonella proliferation. Galectin 8 monitors endosomal and lysosomal integrity and detects bacterial invasion by binding host glycans exposed on damaged Salmonella-containing vacuoles. By recruiting NDP52 (also known as CALCOCO2), galectin 8 activates antibacterial autophagy. Galectin-8-dependent recruitment of NDP52 to Salmonella-containing vesicles is transient and followed by ubiquitin-dependent NDP52 recruitment. Because galectin 8 also detects sterile damage to endosomes or lysosomes, as well as invasion by Listeria or Shigella, we suggest that galectin 8 serves as a versatile receptor for vesicle-damaging pathogens. Our results illustrate how cells deploy the danger receptor galectin 8 to combat infection by monitoring endosomal and lysosomal integrity on the basis of the specific lack of complex carbohydrates in the cytosol.