In most cases, the answer is simple, “yes.”
While some local codes deviate from this, all decks that are built 24 inches above grade (ground level) must have guard rails, and for the most part, these rails must:
Have a minimum height of 36 inches
Have maximum spindle spacing of 4 3/8 inches
Be designed and constructed to withstand a 200-pound load applied from any direction
Installed on stairs with more than three risers (additional requirements apply to stairs)
Whether they are required or not, one can always make an argument to add railing to any deck project.
We have an entire post on the subject here: https://upsidebycolorguard.com/do-i-need-a-deck-rail/