Changing default Grails port used in run-app

May 20

Changing default Grails port used in run-app could be done through different ways. The main difference between these ways is the scope of the change.

Before start changing the port let’s see what’s happening by default. Running an application on GGTS should lead to the following:

default run-app on grails

As you see, the project is running on 8080 by default. Basically there are three different scopes In order to change that port.

  1. Changing the port for a single project on a single run
  2. This is done by using the following command instead of the regular run-app one:

    As you see this will make you choose the port that should be used for this specific run. This means that port will not affect the project or Grails permanently. Testing the above command will lead to the following:

    after changing the port for a single project on a single run

  3. Changing the port for a single project permanently
  4. If you don’t want to type the port every single run you can configure it by adding the following to the project’s BuildConfig.groovy:

    Testing the above configurations will lead to the following:

    after changing the port for a single project permanently

  5. Changing the port for all Grails projects permanently
  6. If you want Grails to always run on a specific port no matter what project you are running there is a configuration file for that. This configuration file doesn’t exists by default so you will have to create it. Depending on the OS your are using go to your user directory and you will find a folder named .grails (create it if it isn’t there). Now create a file with name settings.groovy and add the following line (same line as the one added on method 2):

    Testing the above configurations will lead to the following (you may need to restart GGTS):

    after changing the port for all Grails projects

You are more than welcome to leave a comment If you think there is another scope needs to be added.

2 comments

  1. Nilvandro Muianga /

    Thanks, this was so helpful.

Leave a Reply