ignore collision not working

i am trying to make a gameobject ignore collision with other when it lands on the ground
but that is not happening for some reason? am i doing something wrong?

[SerializeField] GameObject boxGameObject;

private void OnCollisionEnter2D(Collision2D ground)
{
if(ground.gameObject.tag == "Ground")
{
Physics2D.IgnoreCollision(boxGameObject.GetComponent<Collider2D>(), GetComponent<Collider2D>());
}
}

You have the ground collider in Collision2D ground parameter, but you aren’t using it.
Currently lone GetComponents gets you the collider of the current gameObject to which the script is attached to.

Try:
Physics2D.IgnoreCollision(boxGameObject.GetComponent<Collider2D>(), ground.collider);