In the current report synthesis soft magnetic nickel ferrite nanoparticles by hydrothermal and microwave method without using any surfactant. At the second step cadmium sulfide photoluminescence nanoparticles first were prepared without applying surfactant and capping agent at water as a green solvent, then effect of natural and chemical surfactants on the morphology and size of nanoparticles was investigated. NiFe2O4-CdS nanocomposite was synthesized by hydrothermal method. Nanoparticles were entirely characterized using X-ray diffraction pattern, scanning electron microscopy, Fourier transform infrared spectroscopy and vibrating sample magnetometer. NiFe2O4-CdS nanocomposite shows competent photoluminescence property under ultraviolet irradiation. Our results approve this nanocomposite is a novel sensor for detecting of the toxic heavy metal ions. Among toxic heavy metal ions, harmful influences of lead, cadmium and mercury on human health are well known to cause many sicknesses. In this investigation heavy metals and bacteria have been detected by prepared materials. Fluorescent sensors with high selectivity and sensitivity are considered to be the most suitable sensors for detection of heavy metal ions.