Now connect the headboards and footboards together with the 2x4 inner side rails. Bolts, 3" screws or bed brackets here. You could also use pocket hole, but remember, these are the main joints that hold the weight of the bed, so you want to make sure this joint is strong.
Also, if you have a box spring, you can adjust the width to accommodate the box spring exactly. Just remember that the box spring sits on top of the bed rails.