3

I am trying to go to production on one of my node.js applications which runs ion windows server 2012. After a week of troubleshooting and reading everything I could get to online, the problem seems to be the "process.env.PORT" variable.


The symptoms are as follows:

The website works fine when:

set PORT=3510 in console
domain.com:3510/index.html in remote browser

However, when I type:

domain.com

I get a 404 - File or directory not found.


When I console.log the "process.env" object at startup of my server.js, the console.log prints an object with several properties but no "PORT" property (unless I "set PORT=3510"). Without setting the port manually prior to launching the server.js, "process.env.PORT" console.logs reports undefined.

However, If manually specify the port, the server still does not work because, according to what I read, node expects "process.env.PORT" to be a named pipe and not a number.

So the problem is very specific:

How do I set the "process.env.PORT variable" on windows 2012 server so that nodejs can work with it?

chran
  • 119
  • 8

1 Answers1

1

You need to set it in the web.config file. You can set a key as "PORT" with the value you need. See the below web.config file as an example...

<configuration>
    <appSettings>
        <add key="PORT" value="3510" />
    </appSettings>
    ...(Other configurations here)
</configuration>
developthewebz
  • 1,827
  • 3
  • 17
  • 43