I have a surge protector, but the problem was after...
I don't know if a "surge protector" exists for 24V DC ?
Sort of. A well designed AC to DC transformer can absorb a certain amount of abuse, and should be designed in such a way that it fails in a sacrificial manner to prevent the device attached from being exposed to the surge.
Reality is, most generic transformers (wall warts, bricks, etc.) are designed to the cheapest spec, and will pass along any over/under-voltages they receive from the AC mains, usually before they suffer catastrophic failure themselves, if the surge is large enough.
So instead, the option is to provide a surge protector on the 120/240 AC (depending on region) side-- the idea being, you can protect multiple devices with a single surge protector. Ideally, it's some form of capacitor and voltage regulator to smooth out spikes, combined with a circuit breaker that pops in the event of too much voltage. Frequently, it's just a circuit breaker. The faster the response time of the breaker, the better a job it does, but the more likely you are to have occasional false interrupts.
I mentioned a UPS, because in a well-designed battery backup, the power to devices is always coming through the inverter from the battery-- so it's always exactly the right voltage, even if the power input to the battery fluctuates a bit. It's harder on the batteries (expect to replace them every 3 to 5 years), but easier on the protected equipment.