A musty smell is a fairly common occurrence in front-loading washing machines. The smell is result of mould developing in the front gasket due to water retained in the gasket after many wash cycles. Fortunately with the correct cleaning products and method, you can remove the unpleasant odour from your washing machine.
Put on cleaning gloves and a mask before you begin to clean out the mould and mildew form the washing machine. Gloves will protect your hands from the detergent and a mask will prevent any mould spores from going into your lungs, which is important especially if you have a sensitivity or allergy to mould and mildew.
Clean the washing machine's rubber gasket, located on the door, thoroughly with a scrub brush and a borate-based detergent. Follow the instructions on the detergent label; it may instruct you to dilute the detergent with water. Rinse away the borate-based detergent on the rubber gasket with water.
Add a cup of bleach to the washing machine and run a full washing cycle. Do not add detergent or clothes to the machine during this cycle.
Open the door wide when the cycle is complete so that the washer can completely dry out.
Prevent the mould from returning by always leaving the door open every time you are finished using the machine. You can find borate-based detergents at most home goods or cleaning supplies stores.
If you have any small pets, especially cats, make sure that they don't get inside of the washing machine while you are waiting for it to dry out after the washing cycle.