How to change grails localhost port?

Grails

Grails Problem Overview


I'm using grails 2.0.4. And I want to use port:8090 instead of 8080 for localhost. So need help to change the port to 8090 permanently.

Grails Solutions


Solution 1 - Grails

This solution adds to the answers http://stackoverflow.com/a/10956283/122457. In Grails 2.x, add the following to BuildConfig.groovy:

grails.server.port.http = 8090

See http://forum.springsource.org/archive/index.php/t-97024.html for further details.

Solution 2 - Grails

There are two options:

  1. Change grails.serverURL in Config.groovy from "http://localhost:8080/${appName}" to "http://localhost:8090/${appName}".
  2. Launch grails with -Dgrails.server.port.http=8090 on the command line. Set the GRAILS_OPTS environment variable to -Dgrails.server.port.http=8090 to have it applied automatically.

Solution 3 - Grails

If you are using Netbeans IDE then set the following -:

Config: -> BuildConfig.groovy: -> grails.server.port.http = 8090 and restart the server.

Without IDE, type in the command prompt -:

grails -Dserver.port 8090 run-app

or

grails -Dserver.port=8090 run-app

Solution 4 - Grails

For grails 3 you can put this in your application.yml

server:
    port: 9999

Solution 5 - Grails

command line: grails run-app -port 8090

Solution 6 - Grails

Run the command (Ctrl+Alt+g)

  1. Up to grails version 2.x : run-app -Dserver.port=8090
  2. For grails version 3.x : run-app --port=8090

Solution 7 - Grails

If you are using IntelliJ IDE then

From the application menu click Run >> Edit Configurations... >> VM options: -Dgrails.server.port.http=8180

Solution 8 - Grails

grails run-app -Dserver.port=8090

Or use another port number

In Intellij: Ctrl+Alt+G (keyboard Generic); Cmd+Alt+G (keyboard Mac) and use only:

run-app -Dserver.port=8090

Solution 9 - Grails

Add/Update the value of port from your application.yml (grails-app/conf/application.yml)

environments:
   development:
        server:
            port: "8090"

Or

server:
    port: "8090"

Solution 10 - Grails

Type following in the command line:

grails -Dserver.port=8090 run-app

Solution 11 - Grails

You didn't say what IDE you are using. If you are using Netbeans you just right-click on the project name and choose Properties. From the General Settings Category, you can easily change the server port to whatever you like.

Solution 12 - Grails

You can run grails app using the following command on the terminal. default running port is 8080.

grails run-app -Dserver.port=9090

This will run the app on port 9090.

Solution 13 - Grails

For Grails 4 required two settings

server:
   port: "8085"
grails:
   serverURL: http://localhost:8085

Second one will solve redirection issues

Or only for dev:

environments:
    development:
        server:
            port: "8085"
        grails:
            serverURL: http://localhost:8085

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMamun SardarView Question on Stackoverflow
Solution 1 - GrailsChrisView Answer on Stackoverflow
Solution 2 - GrailsataylorView Answer on Stackoverflow
Solution 3 - GrailsGautamView Answer on Stackoverflow
Solution 4 - GrailsWizardsOfWorView Answer on Stackoverflow
Solution 5 - GrailsCadView Answer on Stackoverflow
Solution 6 - Grailsujjwol shresthaView Answer on Stackoverflow
Solution 7 - GrailsJason HeithoffView Answer on Stackoverflow
Solution 8 - GrailsSamuel IvanView Answer on Stackoverflow
Solution 9 - GrailsMahfuz AhmedView Answer on Stackoverflow
Solution 10 - GrailsYaseen MohamedView Answer on Stackoverflow
Solution 11 - GrailsUniversitasView Answer on Stackoverflow
Solution 12 - GrailsSatish KaleView Answer on Stackoverflow
Solution 13 - Grailsdemon101View Answer on Stackoverflow