Principally, all sin in general is against God and must be confessed only to Him in the closet of prayer.Notice that even after David sinned with Bathsheba and killed Uriah, he prayed,“Against thee, thee only, have I sinned, and done this evil in thy sight” (Psalm 51:4). When Achan was identified by God for stealing, his sin was against God and the people. Joshua told him,“My son, I beg you, give glory to the LORD God of Israel, and make confession to Him, and tell me now what you have done; do not hide it from me” (Joshua 7:19 NKJV).
Because his sin directly affected the people, or church, he was commanded to acknowledge this publicly. But the confession was to God, not man—because only God can forgive sin. “I, even I, am He who blots out your transgressions for My own sake; And I will not remember your sins” (Isaiah 43:25 NKJV). But if we hurt, offend, or abuse another human, whether Christian or pagan,we should acknowledge it to them and ask them to forgive us. “Therefore if you bring your gift to the altar, and there remember that your brother has something against you, leave your gift there before the altar, and go your way. First be reconciled to your brother, and then come and offer your gift”(Matthew 5:23, 24 NKJV). The simple rule is this: Public sin should be acknowledged publicly, offenses against individuals should be addressed only with those involved.And private sin should be confessed to God in private.