5v relay module not working with dc adapter
but i changed the source to a mobile charger

Aha! Many mobile chargers (power banks) switch off when the load only draws a small current. This is likely the reason why the power is switched off. The Arduino + relay simply doesn't draw enough current to keep the power bank switched on.

The power bank "thinks" there's nothing connected so it switches off.

Your alternative is to use a power bank that is doesn't switch off at a low current.

You could also increase the load (for example by connecting a 27 ohm, 1 Watt resistor between 5V and GND) to keep the power bank awake but that will very likely drain your power bank much more quickly.