Share via

IIS Reverse Proxy to Python App (NSSM Service) Fails on Port 7777 After Initial Success on Port 3000

Intellient Team 0 Reputation points
2025-09-26T09:45:07.8033333+00:00

I have installed my python app as an nssm service which is running successfully in my remote machine with an IP of 172.xxx.xxx.xx and 7777 port . Then I opened the IIS and did the following steps: 0. I tested http://172.xxx.xxx.xx:7777 and it is working fine 1. I enabled Proxy in the server proxy settings in Application Request Routing 2. I created a new site named Python_App and added a folder named Proxy under the C:/inetpub/wwwroot/Proxy and left the others in it as such. 3. Then I created a new rewrite url inbound+ outbound rule. For the inbound rule, i entered 172.xxx.xxx.xx:7777 and entered the same in the from part of the outbound rule and the client had created a domain name lets call it genai.com and i entered that from the drop down which automatically showed in the to dropdown box. This worked for the first time, that is when i tried with port 3000 and hit the genai.com in my local machine's browser and it worked, and i deleted that and tried the same steps with the updated app in port 7777 but the url did not show the output but Hmmm… can't reach this page genai.com refused to connect.

Azure Virtual Machines
Azure Virtual Machines

An Azure service that is used to provision Windows and Linux virtual machines.


1 answer

Sort by: Most helpful
  1. Himanshu Shekhar 6,325 Reputation points Microsoft External Staff Moderator
    2025-09-26T11:58:12.1166667+00:00

    Hello Intellient Team

    Welcome to Microsoft Q&A Platform. Thank you for reaching out & hope you are doing well.

    1. Is your Python NSSM service running and accessible directly at [http://172.xxx.xxx.xx:7777] from the IIS server machine itself (e.g., using a browser or curl on the IIS server)?
    2. Can you confirm if "Enable Proxy" is checked in IIS Application Request Routing server proxy settings, and do you have the exact inbound and outbound URL rewrite rules configuration you applied for the genai.com site?

    Check URL Rewrite Rules

    Depending on the route of your app, your inbound rule should match all incoming requests to genai.com and rewrite them to http://172.xxx.xxx.xx:7777/{R:1} and Outbound rules should rewrite response URLs (e.g., from http://172.xxx.xxx.xx:7777 back to http://genai.com) if any absolute URLs are returned. The rewrite URL should be consistent with your current backend port (7777).

    After deleting your old site and creating a new one for port 7777, cached DNS or proxy responses can cause "refused to connect" errors.

    Clear your browser cache and IIS server cache/recycle the IIS site or app pool and Confirm Backend Service Availability on Port 7777 and even though direct testing on http://172.xxx.xxx.xx:7777 works on the server, ensure no firewall or network restriction prevents IIS from connecting to port internally.

    ARR or IIS logs may show proxy connection errors or timeouts. Look for errors in IIS logs or Windows Event Viewer for Application or System events.

    Please adjust proxy timeouts (higher value such as 180 seconds or more) if your app takes longer. Also, in ARR proxy settings, try toggling "Reverse rewrite host in response headers" checkbox.

    Additonally, Test-NetConnection -ComputerName 172.xxx.xxx.xx -Port 7777 in PowerShell

    If successful, the port is reachable from the IIS server.User's image

    Even if [http://172.xxx.xxx.xx:7777] works from IIS server, test from the client machine where genai.com is accessed.

    Also check firewall settings on the machine hosting the Python app: and ensure inbound rule allows TCP port 7777.

    User's image

    Additionally please refer Microsoft documentation for details:

    1. Reverse Proxy with URL Rewrite v2 and Application Request Routing : https://learn.microsoft.com/en-us/iis/extensions/url-rewrite-module/reverse-proxy-with-url-rewrite-v2-and-application-request-routing
    2. Troubleshooting 502 errors in ARR :https://learn.microsoft.com/en-us/troubleshoot/developer/webapps/iis/application-request-routing/troubleshooting-502-errors-in-arr
    3. Creating Rewrite Rules for the URL Rewrite Module : https://learn.microsoft.com/en-us/iis/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module
    4. ARR Server Proxy Settings overview and explanation: https://stackoverflow.com/questions/4243959/iis-reverse-proxy-with-rewrites-cant-handle-a-redirect-from-the-server-we-proxy

    Regards

    Himanshu

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.