How to change grails localhost port?
Asked Answered
H

13

98

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.

Heartbeat answered 8/6, 2012 at 20:51 Comment(0)
A
114

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.
Afterimage answered 8/6, 2012 at 21:33 Comment(2)
from the command line you can also just use -Dserver.port=8090Tanganyika
for grails 3 you can only use -Dserver.port=8090Mezereum
C
136

This solution adds to the answers https://mcmap.net/q/216446/-how-to-change-grails-localhost-port. 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.

Cascade answered 3/5, 2013 at 12:27 Comment(4)
This is the better solution. Has less moving parts.Workman
I tried this method and it did not work, is there a specific section in which this should be placed? I stuck it under the grails.project.target.level section, and it appeared to have no effect.Richert
@TedDelezene this doesn't go under any other section. Did you restart the application after changing the configuration? - Because only that would reload the configuration (and your change of it).Volk
Yes I did, and it didn't work for me, however now I just start it with the -Dserver.grails.port.http=49494 option.Richert
A
114

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.
Afterimage answered 8/6, 2012 at 21:33 Comment(2)
from the command line you can also just use -Dserver.port=8090Tanganyika
for grails 3 you can only use -Dserver.port=8090Mezereum
O
36

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
Overcharge answered 5/8, 2014 at 7:22 Comment(3)
Very informative and tells every way to do this. Thanks gautam.Obedient
@Overcharge There was no field like grails.server.port.http in my BuildConfig, so I manually added it and tried but it gave response like 8080 in use(I was using it to deploy using tomcat). What could be the problem I have made. I have put grails.server.port.http = 8090 at the very beginning of BuildConfigYachting
Try to kill all port of 80 and then try. For linux use '' sudo fuser -n tcp -k 80 '' or ' lsof -t -i:8080 ' in terminalOvercharge
W
21

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

server:
    port: 9999
Whydah answered 30/6, 2016 at 22:41 Comment(3)
Or more concisely as server.port: 9999.Anytime
or using jvm option -Dserver.port=9999Flew
Why is this so highly upvoted? The OP asked about grails 2. This answer is entirely irrelevant.Appetizing
D
12

command line: grails run-app -port 8090

Dichotomy answered 18/5, 2016 at 1:14 Comment(4)
This did not work for me, still starts on 8080. Very oddFante
This fixed it for me in IntelliJ IDEA 2017.1.1Discourse
Works for IDEA 2020.1 with Grails 3.3.11. Thanks!Interspace
This simple/easy solution still works well under IDEA 2022.3.1 with Grails 5.3.2: In the Select Run/Debug Configuration dropdown, click on Edit Configurations..., then change the Grails setting Command Line to run-app -port 8090Itinerate
P
6

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
Polyethylene answered 21/12, 2017 at 5:35 Comment(0)
S
5

If you are using IntelliJ IDE then

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

Savour answered 7/1, 2015 at 21:20 Comment(0)
S
5

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

Suicide answered 20/11, 2015 at 2:43 Comment(4)
This did not work for me either, still starts on 8080Fante
What version of Grails you have?Suicide
Same here, it didn't worked for me. I am on grails 1.3.7 running on Mac OS 13.12.3. I think it is not OS specific issue.Quisling
Check the guide in the section: 2.7 Running an Application... docs.grails.org/1.3.7/guide/single.html You can specify a different port by using the server.port argument: grails -Dserver.port=8090 run-appSuicide
E
3

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

environments:
   development:
        server:
            port: "8090"

Or

server:
    port: "8090"
Emelia answered 18/3, 2021 at 1:55 Comment(0)
P
1

Type following in the command line:

grails -Dserver.port=8090 run-app
Prospective answered 4/8, 2018 at 5:18 Comment(0)
F
0

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.

Furculum answered 11/6, 2012 at 20:57 Comment(0)
S
0

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.

Shenyang answered 27/3, 2018 at 4:47 Comment(0)
M
0

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
Mezereum answered 21/4, 2022 at 16:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.