Starting server on alternate ports. #534

Closed
sebv opened this Issue Nov 18, 2012 · 6 comments

Comments

Projects
None yet
6 participants
@sebv

sebv commented Nov 18, 2012

Is it possible? The code below seems to imply that only one set of port/base can be configured in Gruntfile.

var port = grunt.config('server.port') || 8000;
var base = path.resolve(grunt.config('server.base') || '.');
@shama

This comment has been minimized.

Show comment Hide comment
@shama

shama Nov 18, 2012

Owner

You can configure your Gruntfile to use alternate ports like this:

grunt.initConfig({
  server: {
    port: grunt.option('port') || 8000
  }
});

which will use port 8000 unless you specify a different one with: grunt server --port 9000.

Owner

shama commented Nov 18, 2012

You can configure your Gruntfile to use alternate ports like this:

grunt.initConfig({
  server: {
    port: grunt.option('port') || 8000
  }
});

which will use port 8000 unless you specify a different one with: grunt server --port 9000.

@sebv

This comment has been minimized.

Show comment Hide comment
@sebv

sebv Nov 18, 2012

Ok thanks, and then I should be able to use server as a subtask and configure the port option in the master task.

sebv commented Nov 18, 2012

Ok thanks, and then I should be able to use server as a subtask and configure the port option in the master task.

@tkellen tkellen closed this Dec 7, 2012

@jzacsh jzacsh referenced this issue in thanpolas/generator-closure Aug 31, 2013

Merged

allow overriding hostname and port of grunt server. #14

@callumlocke

This comment has been minimized.

Show comment Hide comment
@callumlocke

callumlocke May 13, 2014

for anyone else struggling to make this work: you need an equals sign when setting options from the command line, eg:

$ grunt serve --port=9000

for anyone else struggling to make this work: you need an equals sign when setting options from the command line, eg:

$ grunt serve --port=9000
@shama

This comment has been minimized.

Show comment Hide comment
@shama

shama May 13, 2014

Owner

Another option if you want to dynamically set to an available port is: https://github.com/shama/grunt-openport

Owner

shama commented May 13, 2014

Another option if you want to dynamically set to an available port is: https://github.com/shama/grunt-openport

@dportabella

This comment has been minimized.

Show comment Hide comment
@dportabella

dportabella Aug 16, 2016

if Gruntfile.js contains:

    express: {
      options: {
        port: process.env.PORT || 9000
      },

then you can change the port as follows:
$ PORT=8999 grunt serve

if Gruntfile.js contains:

    express: {
      options: {
        port: process.env.PORT || 9000
      },

then you can change the port as follows:
$ PORT=8999 grunt serve

@MdShuaib

This comment has been minimized.

Show comment Hide comment
@MdShuaib

MdShuaib Apr 13, 2018

open Gruntfile.js and search for:

options: { port: 9000, // Change this to port:9001hostname: 'localhost', livereload: 35729 // Change this to 35728 },

Just in case you want to run two grunt server at the same time

open Gruntfile.js and search for:

options: { port: 9000, // Change this to port:9001hostname: 'localhost', livereload: 35729 // Change this to 35728 },

Just in case you want to run two grunt server at the same time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment