A washing machine comprising: a body; a tub provided inside of the body to store water; a detergent supply unit disposed adjacent to the tub to supply detergent to the tub during an operating mode for washing laundry and to receive water during a cleaning mode; and a controller configured to allow a cleaning of the detergent supply unit to be performed by controlling a flow of water of the detergent supply unit and the tub during the cleaning mode of the detergent supply unit; wherein the detergent supply unit comprises a detergent storage having a housing fixedly installed in the body; a detergent container placed inside of the housing to store the detergent and configured to be withdrawable to the outside and provided with an opening; and a cover configured to open and close the opening; and a detergent discharge unit configured to discharge the detergent of the detergent storage based on a command of the controller, a door configured to open and close an inlet formed in the tub; characterized in that the detergent supply unit is disposed in a lower portion of the front side of the body, and the washing machine further comprises a first detector configured to detect whether the door is closed or not; and a second detector configured to detect whether the detergent container is separated or not, wherein, when controlling cleaning the detergent supply unit, the controller determines whether the door is closed, based on a detection signal of the first detector and determines whether the detergent container is separated, based on a detection signal of the second detector, and when it is determined that the door is closed and the detergent container is separated from the housing, the controller controls cleaning of the detergent supply unit. a body; a tub provided inside of the body to store water; a detergent supply unit disposed adjacent to the tub to supply detergent to the tub during an operating mode for washing laundry and to receive water during a cleaning mode; and a controller configured to allow a cleaning of the detergent supply unit to be performed by controlling a flow of water of the detergent supply unit and the tub during the cleaning mode of the detergent supply unit; wherein the detergent supply unit comprises a detergent storage having a housing fixedly installed in the body; a detergent container placed inside of the housing to store the detergent and configured to be withdrawable to the outside and provided with an opening; and a cover configured to open and close the opening; and a detergent discharge unit configured to discharge the detergent of the detergent storage based on a command of the controller, a door configured to open and close an inlet formed in the tub; characterized in that the detergent supply unit is disposed in a lower portion of the front side of the body, and the washing machine further comprises a first detector configured to detect whether the door is closed or not; and a second detector configured to detect whether the detergent container is separated or not, wherein, when controlling cleaning the detergent supply unit, the controller determines whether the door is closed, based on a detection signal of the first detector and determines whether the detergent container is separated, based on a detection signal of the second detector, and when it is determined that the door is closed and the detergent container is separated from the housing, the controller controls cleaning of the detergent supply unit.