This paper presents an EMQ model which determines an optimal production quantity in an unreliable machine. A machine is subject to a random failure from an in-control state to an out-of-control state and thus produces some proportion of defective items. It is assumed that a sensor, which is also failure prone, is attached to the machine to monitor the machine continuously and detects its state promptly. It is discussed how to determine EMQ when the time between failures of a machine as well as a sensor is exponentially distributed. Through a numerical experiment, the behavior of the proposed model is investigated, and variations of an EMQ depending on the performance of the sensor are also examined.