globalinfo wrote: Tests I carried out with relays alone without pumps and solenoid valve connected - it did not hang up.
In addition to this, 2 more relays are used to switch the fans on and off at 5V - it does not hang up either.
Only when the solenoid valve closes.
.
I see two possibilities - either something is "sowing" on the mains, or the solenoid valve is generating some large electromagnetic interference.
To eliminate the first possibility connect (for a test) the solenoid valve to a different phase, or as colleagues advised power your system from the battery.
To eliminate the second possibility, move both systems as far apart as possible - first the solenoid valve from the ESP + relay, and if that doesn't help, leave the relay at the solenoid valve and move the ESP away.
If this does not work either, power the relay circuit from an independent power supply, so that ESP is only connected to the optocoupler diode (without equalizing the ground potentials of both circuits, i.e. with full galvanic isolation on the optocoupler).