A door opening and closing device for a refrigerator, a door of the refrigerator being rotatably connected with a refrigerator body by means of a rotating shaft of the device, wherein the rotating shaft is suitable to be fixedly connected with the door and a shaft hole is formed in the rotating shaft, the door opening and closing device comprising: a connecting rod configured to releasably engage with the shaft hole, wherein the connecting rod includes a first end and a second end that matches the shaft hole; a first drive means connected with the connecting rod and configured to drive the connecting rod to rotate; a second drive means configured to drive the connecting rod to move close to the shaft hole, and cause the second end of the connecting rod to be inserted into the shaft hole, wherein the second drive means is an electromagnet, wherein a first through hole matching the first end of the connecting rod is formed in the electromagnet, and wherein the first end of the connecting rod penetrates the first through hole and when the electromagnet is powered on, the electromagnet attracts the connecting rod to cause the connecting rod to move close to the shaft hole; an elastic member, wherein after the second end of the connecting rod is inserted into the shaft hole, the elastic member is compressed, so that the elastic member can drive the connecting rod to move away from the shaft hole, wherein the elastic member is supported between the first end of the connecting rod and an end face of the electromagnet away from the shaft hole, and wherein after the electromagnet drives the second end of the connecting rod to be inserted into the shaft hole, the first drive means drives, by means of the connecting rod, the rotating shaft to rotate, so as to make the door rotate relative to the refrigerator body. a connecting rod configured to releasably engage with the shaft hole, wherein the connecting rod includes a first end and a second end that matches the shaft hole; a first drive means connected with the connecting rod and configured to drive the connecting rod to rotate; a second drive means configured to drive the connecting rod to move close to the shaft hole, and cause the second end of the connecting rod to be inserted into the shaft hole, wherein the second drive means is an electromagnet, wherein a first through hole matching the first end of the connecting rod is formed in the electromagnet, and wherein the first end of the connecting rod penetrates the first through hole and when the electromagnet is powered on, the electromagnet attracts the connecting rod to cause the connecting rod to move close to the shaft hole; an elastic member, wherein after the second end of the connecting rod is inserted into the shaft hole, the elastic member is compressed, so that the elastic member can drive the connecting rod to move away from the shaft hole, wherein the elastic member is supported between the first end of the connecting rod and an end face of the electromagnet away from the shaft hole, and wherein after the electromagnet drives the second end of the connecting rod to be inserted into the shaft hole, the first drive means drives, by means of the connecting rod, the rotating shaft to rotate, so as to make the door rotate relative to the refrigerator body.