Use of kukoamine A and kukoamine B in preparing medicine for preventing and treating sepsis and autoimmune diseases. The kukoamine A and kukoamine B are extracted from cortex lycii radicis. The medicine is used for antagonism of bacterial endotoxin (LPS) and bacteria non-methylated DNA (CpG DNA).