Solution
The VISA address of the COM port should not include the IP if the code is running on the target. Make sure that your VISA address looks similar to the image below and does not include an IP address:
In the example above if you use the address GPIB0::5::INSTR instead of visa://169.254.104.28/GPIB0::5::INSTR then the error will go away.