Mistake 9: Incorrectly attaching guardrail posts
The error: Insufficiently connecting a guardrail post to a deck is among the most dangerous deck-building errors. Fastening guardrails to deck rim joists or floor joists with wood screws is not acceptable. While some builders get the guardrail-to-rim-joist connection correct, they don’t always ensure that the rim joist is attached to the deck framing properly.
The solution: The code (table R301.5) requires a guardrail to be capable of resisting a concentrated load of 200 lb. in any direction along its top. Depending on the design of the guard assembly, a stout guardrail-post-to-deck connection can be accomplished with blocking and through-bolts or with horizontally oriented hold-down hardware. In some rail designs, most of the load resistance is handled by the post connection to the deck. In those instances, the post should be attached to the joists, not the rim, because the rim is not usually fastened to the joists in a manner capable of transferring the load. Rims are typically nailed into the end grain of the joist, the weakest possible connection for withdrawal resistance.
The design methods for guardrail assemblies are as vast as the imagination, and homeowners admire that creative expression. However, serious consideration must be made as to how the guardrail is ultimately assembled.
The strength of a guardrail assembly is provided by a lot more than just the post-to-deck connection. The concentrated load must be resisted at any point along the top of the rail. With a common 5-ft. to 6-ft. distance between the posts, the load must transfer through the connection of the horizontal rails to the post. When a continuous top cap runs across the posts, it acts like a horizontal beam to help distribute the load over a larger area. When a post is run long, through the top of the guardrail, there is a considerable reduction in strength.

Don’t use nails or screws to fasten railing posts to deck framing, use bolts.
Use blocking and bolts to create a stronger railing than one with posts connected to rim joists that are nailed only to the end grain of the joists.