I had an issue with my standard sized docking ports and learning docking. Even though I had everything lined up (was using docking port alignment mod), the magnets were not kicking in, and after hours of trying, could not make the connection. I had ensured power to both ships, and correct docking port alignment (neither part was backwards).
I found an old bug report from 2013 about a problem that can happen to the state of the docking port, as recorded in the save file. I made a backup of my save file, and searched for 'state = acquired', found an entry and found that the port corresponded to one of the vessels I was attempting to dock. I changed the entry to 'state = ready', but still had the same issue with being unable to dock. I looked at the file again, and on the port, there was an entry for 'dockUId' right below the 'state =' line I had changed. I set dockUId to = 0 (kept the 'state = ready' change, rather then the 'state = acquired' that it was previously set to), loaded the save, and they docked almost immediately. I'm guessing dockUId records what part the port is docked to.
I had been making quicksaves during the docking process, when I had everything lined up and was ready to close distance, and after reading the bug report, and a few other posts, concluded that the saving during the closing seconds of docking may have caused an error in the save.