Servo moves while the signal isn't even attached

so my servo randomly (and voilantly) starts to move after a little while of being turned on. the servo i am using is a TD-8125MG 25kg 180° servo.
the previous servo was a TD-8120MG 20kg 180° servo.

i had the same problem with a previous servo on the same spot. that servo doesn't work with my arduino but does work with a servo tester but that is a different story.
i replaced that 'broken' servo with a brand new one, tested it with the servo tester and installed it, ran a code to check of it worked and it did. but, now just like the other one it randomly starts moving even though the code doesn't say anything for that servo, and it also happens when i detatch the servo pin.
i don't think it happens when the servo is mentioned in the code but i still want i fixed or alteast find out why?

the test code:

#include<Servo.h>

Servo servo;

void setup() {
  
servo.attach(5);
servo.write(90);

}

void loop() {

servo.write(80);
delay(800);
servo.write(90);
delay(800);
servo.write(100);
delay(800);
servo.write(90);
delay(800);
}

I suspect that you need to provide the PWM signal to the servo, otherwise it will likely do as you describe. Many years ago it happened with my old 27MHz RC setup when the signal wire broke on a servo.

yeah i know but sometimes i am running a code to test something else and i don't that servo to keep moving while im just testing something.
it's like that spot has a servo ghost haunting servo's

Once you have used servo.attach() the Arduino will always be "saying" something for that servo. What happens if you leave the loop() function empty ?

Which Arduino are you using and how is the servo powered and connected to the Arduino ?

it did just came to my mind that that servo is under a NEMA23 stepper motor with just a small bit of PLA inbetween.
could the permanent magnets of the stepper motor be interfering with the servo?

Just put a servo.attach() in setup and the servo will move to 90 degrees and stay there unless you write to the servo pin

yeah thats also an option.

do you mabye have an idea why a servo doesn't work with an arduino but it does work with a servo tester?
for the arduino it has an external power supply.

or configure the pin as output

OK, but where is the servo powered from ?

from an external power supply

Servos do jitter a little bit when they're on. Any chance that is what you see? Else, if it is responding to noise on the control line because it is high impedance, make the pin an output and the noise will stop.

if jitter means turning 60+ degrees very fast, then yes.

the servo also moves when the pin isn't in the arduino so i don't think that will help.

What voltage is the external power supply ?
Is the servo 5V line connected to the Arduino ?

If this happens when you run the test code that you posted, it's more likely a wiring or power supply issue.

it is power by a 6s (22.2V) 5000mAh li-po battery that connects to a 200W V.reg that brings it down to 6V.

One more time

checked the wiring and the power supply is ok i think, so i think i just gonna give up and live with it.

no, only the signal wire

You can, but it's definitely not normal behaviour.