A few years ago, I purchased 5 MCP23017 I/O expanders, and I used one on a project with a ProMicro with no problem at all. Recently, I tried to connect one to a NodeMCU, along with a DS2321 RTC on the I2C bus. I got no response at all from the MCP.
I used some scanning code, and still nothing (it read the RTC addresses OK). I tried different libraries, nothing. In desperation, I decided that maybe the board was bad. But the second also failed to respond. Checked my wiring every which way (four wires!). I looked at my old working project, and noticed the board was slightly different, silk screen was different.
Finally, I look at the IC under a magnifying glass, and see that my "MPC23017" board has a MCP23S17 chip on it. The "S" is the version that uses the SPI interface (the board is set up to accommodate either), so no wonder it didn't work! I've got more on order now.
So, if you are having problems with your MCP23017 or MCP23S17, verify you have the right chip! This drove me crazy!
The boards I bought are similar to this (it was years ago, a different vendor, and prices have gone up - chip shortage?):