Invoke-RestMethod : The operation has timed out


I have a script that deletes resources and creates new ones. Every now and then it times out and I can’t figure out why. It seems to happen when I run the script multiple times, but I couldn’t get a definite pattern. I found that my server hasn’t picked up the message yet since there’s no logging for the request yet.

Interesting note, I get occasional timeouts when I run the Invoke-RestMethod calls directly from powershell. I also ran them with Fiddler and never got timeouts.

[Edit] I’ve been checking the connections with netstat. While the commands are hanging, they’re listed as ESTABLISHED. But I keep seeing TIME_WAIT connections listed to my server. Is there a chance my connections aren’t getting closed?


The link David Brabant posted above contains this workaround that solved the problem for me:


Invoke-RestMethod : The operation has timed out by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply