Search code examples
gruntjscloud9-ide

How to use grunt serve in Cloud9 IDE?


In my Gruntfile.js I have tried to do this:

connect: {
  options: {
    port: process.env.PORT,
    hostname: process.env.IP,
    livereload: 35729
  }
}

I tried to run from Cloud 9 terminal and I get the following:

Running "serve" task

Running "concurrent:server" (concurrent) task

Running "connect:livereload" (connect) task Fatal error: Port 8080 is already in use by another process.

Then I have changed my Gruntfile.js to the following:

connect: {
  options: {
    port: 9000,
    hostname: process.env.IP,
    livereload: 35729
  }
}

From the terminal I get:

Running "serve" task

Running "concurrent:server" (concurrent) task

Running "connect:livereload" (connect) task Started connect web server on http://0.0.0.0:9000

Running "watch" task Waiting...

But how do I access http://0.0.0.0:9000 from Cloud 9? I have tried http://localhost:9000, http://127.0.0.1:9000, am I missing something here?


Solution

  • Update: On Cloud9, you can use ports 8080, 8081, and 8082 to make this work. For details and an example, you can look at Multiple Ports.


    In Cloud9, port 8080 is the only externally accessible port, so please change 9000 to 8080. The port is in use by another process, which should be stopped first. Use:

    kill -9 $(lsof -i:8080 -t)
    

    and restart grunt. That will work.