title: Deploying Node App in IIS
body: <p>I'm trying to deploy node app on windows server 2012 R2 and facing issue while doing the same.</p>
  
  <p>Server: Windows Server 2012 R2</p>
  
  <p>1) I've installed IIS node from <a href="https://github.com/tjanczuk/iisnode/wiki/iisnode-releases" rel="nofollow noreferrer">https://github.com/tjanczuk/iisnode/wiki/iisnode-releases</a> [iisnode for iis 7/8(x64)]</p>
  
  <p>2) Installed URL Rewrite module from <a href="https://www.iis.net/downloads/microsoft/url-rewrite" rel="nofollow noreferrer">https://www.iis.net/downloads/microsoft/url-rewrite</a></p>
  
  <p>3) Placed all node app files at a certain location.</p>
  
  <p>4) From that project directory, issued <em>npm install</em> to install required packages.</p>
  
  <p><strong><em>server.js</em></strong></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>require('rootpath')();
  var express = require('express');
  var app = express();
  var cors = require('cors');
  var bodyParser = require('body-parser');
  var config = require('config.json');
  
  
  app.use(cors());
  app.use(bodyParser.urlencoded({ extended: false }));
  app.use(bodyParser.json());
  
   
  // routes
  app.use('/users',  require('./services/user.service'));
  app.use('/tools',  require('./services/tool.service'));
  app.use('/orders', require('./services/order.service'));
  app.use('/util',   require('./services/util.service'));
  
  // start server
  var port = 9025;
  
  
  var server = app.listen(port, function () {
      console.log('Server listening on port ' + port);
  });</code></pre>
  </div>
  </div>
  </p>
  
  <p><strong><em>web.config</em></strong></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>&lt;configuration&gt;
     &lt;system.webServer&gt;
  
       &lt;!-- indicates that the server.js file is a node.js application 
       to be handled by the iisnode module --&gt;
  
       &lt;handlers&gt;
         &lt;add name="iisnode" path="server.js" verb="*" modules="iisnode" /&gt;
       &lt;/handlers&gt;
  
       &lt;!-- use URL rewriting to redirect the entire branch of the URL namespace
       to server.js node.js application; for example, the following URLs will 
       all be handled by server.js:
       
           
       --&gt;
  
       &lt;rewrite&gt;
         &lt;rules&gt;
           &lt;rule name="rewriteRule"&gt;
             &lt;match url="/*" /&gt;
             &lt;action type="Rewrite" url="server.js" /&gt;
           &lt;/rule&gt;
         &lt;/rules&gt;
       &lt;/rewrite&gt;
  
       &lt;!-- exclude node_modules directory and subdirectories from serving
       by IIS since these are implementation details of node.js applications --&gt;
       
       &lt;security&gt;
         &lt;requestFiltering&gt;
           &lt;hiddenSegments&gt;
             &lt;add segment="node_modules" /&gt;
           &lt;/hiddenSegments&gt;
         &lt;/requestFiltering&gt;
       &lt;/security&gt;    
       
     &lt;/system.webServer&gt;
   &lt;/configuration&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Then using IIS, I've created one website who refers to this particular project folder. Provided port number as 9025 while creating website. When I'm trying to access this URL from other machine i.e. <a href="http://servername:9025/" rel="nofollow noreferrer">http://servername:9025/</a> I'm getting the below error:
  <a href="https://i.stack.imgur.com/E7EQl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/E7EQl.png" alt="enter image description here"></a></p>
  
  <p>I even tried using process.env.PORT instead of directly using 9025. At that time I'm getting 404 not found.</p>
  
  <p>Please let me know what am I doing wrong?</p>