Common limit switch problem

I’m trying to insert homing function on my CNC machine, but when give command $H it appears:

“An unexpected error was detected: (ALARM:1) Hard limit has been triggered. Machine position is likely lost due to sudden halt. Re-homing is highly recommended. [MSG:Reset to continue]”

I inserted the ceramic capacitors between the signal pin and GND of the limit switches. Something interesting is that if it were noisy, probably during gcode compilation the limit switches would be activated, and they are only activated when homing ($H).

GRBL settings and limit switch diagram:

Grbl 1.1h [‘$’ for help]
$0 = 10 (Step pulse time, microseconds)
$1 = 25 (Step idle delay, milliseconds)
$2 = 0 (Step pulse invert, mask)
$3 = 2 (Step direction invert, mask)
$4 = 0 (Invert step enable pin, boolean)
$5 = 1 (Invert limit pins, boolean)
$6 = 0 (Invert probe pin, boolean)
$10 = 2 (Status report options, mask)
$11 = 0.010 (Junction deviation, millimeters)
$12 = 0.002 (Arc tolerance, millimeters)
$13 = 0 (Report in inches, boolean)
$20 = 0 (Soft limits enable, boolean)
$21 = 1 (Hard limits enable, boolean)
$22 = 1 (Homing cycle enable, boolean)
$23 = 2 (Homing direction invert, mask)
$24 = 25.000 (Homing locate feed rate, mm/min)
$25 = 500.000 (Homing search seek rate, mm/min)
$26 = 244 (Homing switch debounce delay, milliseconds)
$27 = 20.000 (Homing switch pull-off distance, millimeters)
$30 = 1000 (Maximum spindle speed, RPM)
$31 = 0 (Minimum spindle speed, RPM)
$32 = 0 (Laser-mode enable, boolean)
$100 = 75.000 (X-axis travel resolution, step/mm)
$101 = 80.000 (Y-axis travel resolution, step/mm)
$102 = 250.000 (Z-axis travel resolution, step/mm)
$110 = 2500.000 (X-axis maximum rate, mm/min)
$111 = 2500.000 (Y-axis maximum rate, mm/min)
$112 = 150.000 (Z-axis maximum rate, mm/min)
$120 = 30.000 (X-axis acceleration, mm/sec^2)
$121 = 30.000 (Y-axis acceleration, mm/sec^2)
$122 = 2.000 (Z-axis acceleration, mm/sec^2)
$130 = 300.000 (X-axis maximum travel, millimeters)
$131 = 300.000 (Y-axis maximum travel, millimeters)
$132 = 20.000 (Z-axis maximum travel, millimeters)

Detail: I disabled Z axis homing, my CNC is a COREXY.

someone more knowledgable than me will be along, but I believe it is because of this:

$21 = 1 (Hard limits enable, boolean)

1 is true, 0 is off, if I am wrong then it is because of this:
$20 = 0 (Soft limits enable, boolean)

and 0 is on, and 1 is off, but that does not make sense to me, I think it is the first one. Need to turn off Hard limiit.

that means it will not move negative.

In this case, $21=0 means that limit switches would be deactivated

I mean hard limit actived = limit switch connected to GRBL

I see you’ve got $5 = 1. According to https://www.diymachining.com/downloads/GRBL_Settings_Pocket_Guide_Rev_B.pdf,
This [$5] refers to the limit switch pins which by default are set to high using the Arduino’s internal pull up resistors. Grounding the pin tells GRBL the limit switch is tripped. For the opposite behavior use the setting $5=1 which tells the system that a high is the limit switch trigger. You must also install external pull down resistor with the $5=1 setting.

Do you have external pull-down resistors?