Timeout Issue with Invoke-WebRequest in PowerShell for Java 17/Tomcat 10

September 23, 2025 3 answers
Asked by TechieNinja42
I'm using a health-check script in Jenkins that runs on Windows PowerShell 5.1. The script tries to access an HTTPS endpoint like this: `$response = Invoke-WebRequest -Uri "https://${IP_Name}:2443/ngat-service/admin/health" -UseBasicParsing -TimeoutSec 600`. It works perfectly fine with our Java 8 + Tomcat 8 application, but with our new Java 17 + Tomcat 10 setup, I keep hitting a timeout error: `Invoke-WebRequest : The operation has timed out.` I've confirmed that the endpoint is reachable using `Test-NetConnection`, and even `curl` can access it, although it takes about 7 minutes to get the full HTML back. My script is set to force TLS 1.2 and to ignore certificate validation. Has anyone faced a similar issue? Any tips on resolving this would be greatly appreciated!

Answers

PowerUser123
Have you thought about running your script in PowerShell 7? I had a similar problem recently, and updating to PS7 and tweaking some syntax surprisingly resolved my issue. It might be a quick fix!
Reply to this answer
QuickFix101
A 7-minute response time definitely sounds like something's off with the app. It might be worth digging into the Java 17/Tomcat 10 configuration to see if there's a performance hitch causing the delay. If everything else is passing, this could be where the issue lies.
Reply to this answer
DebugMaster99
Are you checking if Java is properly bound to the necessary ports? You mentioned that port 2443 is reachable according to your `Test-NetConnection`, which is great. Just be careful with the `httpRuntime executionTimeout` you found in the web.config. That setting can definitely lead to timeouts if they don't match your needs.
Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions