A locking device for a coffee machine, characterized by: a lower main body having an unlocking piece and at least one first engaging portion; an upper cover connected pivotally to and openably covering said lower main body; and a locking mechanism including a first locking member pivotally mounted on said upper cover, a second locking member pivotally mounted on said upper cover in proximity to said first locking member, a locking spring urging said first and second locking members (62, 64) to move toward each other to a locking position, and a handle mounted on said upper cover and engaged to said first locking member to control pivoting of said first locking member, said first locking member including a primary locking plate having a first retaining portion, and a second engaging portion releasably engageable with said first engaging portion, said second locking member having a second retaining portion releasably engageable with said first retaining portion, and an unlocking portion corresponding to said unlocking piece; wherein, when said upper cover is in a covering position, said second engaging portion engages said first engaging portion, and said unlocking piece abuts against and pushes said unlocking portion to disengage said second retaining portion from said first retaining portion and to dispose said first and second locking members (62, 64) in an unlocking position; wherein, when said upper cover is in an open position, said handle drives said first locking member to pivot, said second engaging portion disengages from said first engaging portion, said unlocking piece does not abut against said unlocking portion, and said locking spring pulls said first and second locking members (62, 64) toward engagement with each other to switch said first and second members (62, 64) from the unlocking position to the locking position. a lower main body having an unlocking piece and at least one first engaging portion; an upper cover connected pivotally to and openably covering said lower main body; and a locking mechanism including a first locking member pivotally mounted on said upper cover, a second locking member pivotally mounted on said upper cover in proximity to said first locking member, a locking spring urging said first and second locking members (62, 64) to move toward each other to a locking position, and a handle mounted on said upper cover and engaged to said first locking member to control pivoting of said first locking member, said first locking member including a primary locking plate having a first retaining portion, and a second engaging portion releasably engageable with said first engaging portion, said second locking member having a second retaining portion releasably engageable with said first retaining portion, and an unlocking portion corresponding to said unlocking piece; wherein, when said upper cover is in a covering position, said second engaging portion engages said first engaging portion, and said unlocking piece abuts against and pushes said unlocking portion to disengage said second retaining portion from said first retaining portion and to dispose said first and second locking members (62, 64) in an unlocking position; wherein, when said upper cover is in an open position, said handle drives said first locking member to pivot, said second engaging portion disengages from said first engaging portion, said unlocking piece does not abut against said unlocking portion, and said locking spring pulls said first and second locking members (62, 64) toward engagement with each other to switch said first and second members (62, 64) from the unlocking position to the locking position.