You need at least 6 blocks of space to place a bed in your Terraria house. This allows enough room for the bed to fit and for you to comfortably access it.