In Grails3 grails -Dserver.port=9001 run-app
doesn\'t appear to work:
I\'m \"getting address already bound 8080\".
You can use
server:
port: 9001
in application.yml
.
Or you can pass it via system environment. (e.g. SERVER_PORT=9001 grails run-app
).
grails run-app --port=8081
Or in interactive mode:
run-app --port=8081
Don't forget to use the same port when you want to stop the server:
stop-app --port=8081
I believe this feature was broken in 3.0.3 and earlier versions but it definitely works in 3.0.4.
Accepted answer is correct. For some additional info, Grails 3 uses spring-boot and the server properties are configured by the
org.springframework.boot.autoconfigure.web.ServerProperties
class. "port" is just a property on this class which is filled from the application.yml with the prefix "server". So in addition to the port, you can set properties of this class including tomcat configuration properties and etc. To change the contextPath for instance you add
server:
contextPath: /myapp
to you application.yml.
server:
port: 9809
contextPath: '/admin/'
you can use this in your application.yml file
or change the port depends on the environment for example :
environments:
test:
grails:
serverURL: "http://localhost:9809"