To protect yourself, you should "tender" the rent, by sending a cashiers check by certified mail, return receipt requested. He doesn't need to accept it, but at least you will have proof you tried. He must have some reason for refusing your rent. I assume you were late, or violated the terms of the lease some other way. If so, he does not have to accept the rent, and can evict you. He must comply with notice and service requirements, but that subject is too lengthy to address here.
I am assuming that when the rent was due, the landlord sent you a 3 day notice to pay rent or quit. During those 3 days, the landlord had the legal duty to accept your rent. You had the option of paying or moving. AFTER those three days passed, you became "guilty of unlawful detainer" and the landlord has the right to sue you to evict you. If he accepted the rent past the 3 days, he would have waived his right to evict you.
For some reason, the landlord would rather evict you than take your money now. That is his choice. However, you might have a defense to the unlawful detainer action and, if you win the lawsuit, the landlord will have to accept your rent. You should hire an experienced landlord-tenant attorney to represent you at the unlawful detainer trial. If he or she can identify a defense, you will likely be able to stay in your apartment.