It is because of the board , if you are using node mcu it has a separate pin configuration , if generic 8266 it consist of specific pin config. See the config of your board on the net and then change the D5 pin name.
Yes , I too faced the problem Actually this project has many bugs , I changed the relay circuit in default on portion. After I completed all these setups , this project sometimes works ,and sometimes not I faced many difficulties around this .