Search code examples
node.jsgulpgulp-watchkeystonejs

How to change keystone port#?


I already have another node CMS app running on default port 3000.I know that when creating a node app we specify the port# in index or app.js. In package.json the start is: node keystone.js but when i do that it says that port is already in use, which is by my other CMS app. I've already check the gulp file. This is a keystonejs getting start CMS

There files are in the main directory: .env file gulpfile keystone.js which is the main file procfile


Solution

  • Keystone uses the port setting which falls back to process.env.PORT, process.env.OPENSHIFT_NODEJS_PORT and ultimately 3000. There's a number of ways you can change this, either by setting the port in your keystone.js file, like this:

    keystone.init({
        name: 'My App',
        brand: 'My App',
        port: 3010
        //...
    });
    

    or

    keystone.set('port', 3010);
    

    Or you can set the PORT environment variable in your .env file:

    PORT=3010
    

    The latter one has my preference, since that way I can assign different ports on different environments.