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.
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.
There are two options:
Change grails.serverURL in Config.groovy from "http://localhost:8080/${appName}" to "http://localhost:8090/${appName}".
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.
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
For grails 3 you can put this in your application.yml
server:
port: 9999
command line: grails run-app -port 8090
Run the command (Ctrl+Alt+g)
Up to grails version 2.x : run-app -Dserver.port=8090
For grails version 3.x : run-app --port=8090
If you are using IntelliJ IDE then
From the application menu click Run >> Edit Configurations... >> VM options: -Dgrails.server.port.http=8180
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
Add/Update the value of port from your application.yml (grails-app/conf/application.yml)
environments:
development:
server:
port: "8090"
Or
server:
port: "8090"
Type following in the command line:
grails -Dserver.port=8090 run-app
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.
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.
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
Related
I have setup SSL within my Grails 3.3 application as follows and it works appropriately.
environments:
development:
server:
port: 8443
ssl:
enabled: true
key-store: './localkeystore'
key-store-password: 'localonly'
key-password: 'localonly'
However, I have to manually change the URL to https in the browser. I am using IntelliJ IDEA to deploy locally with the Gradle bootRun command. The deployment log shows the URL upon deployment as unsecure. How can I change this URL to https?
Grails application running at http://localhost:8080/application in
environment: development
If you are running the application with the Gradle bootRun command:
Open build.gradle file and add following configuration there:
bootRun {
systemProperty 'server.port', '8443'
systemProperty 'server.ssl.enabled', 'true'
systemProperty 'server.ssl.key-store', './localkeystore'
systemProperty 'server.ssl.key-store-password', 'localonly'
systemProperty 'server.ssl.key-password', 'localonly'
}
Hope this helps you.
Edit the run configuration for your grails application and add -https option to the command line.
It would be : grails run-app -https ...
In Grails 3.0.9, I want to change the port for run-app, I have modified application.yml:
server:
port: 9000
context-path: '/#info.app.name#'
then I run-app, this is the result:
http://localhost:9000/#info.app.name#
why is it not the name of project?
How do we change the default port 8080 to something else in Grails 3.0.9?
Through command line
This answer has a way which works
grails run-app --port=8090
Also, while stopping
grails stop-app --port=8090
The following may or may not work depending on grails version
grails run-app -Dserver.port=8090
Through configuration
Say to change it to 8090, add the following snippet to grails-app/conf/application.yml
server:
port: 8090
under
environments:
development:
so that it looks like
environments:
development:
server:
port: 8090
In Grails3 grails -Dserver.port=9001 run-app doesn't appear to work:
I'm "getting address already bound 8080".
Any idea how to do this - ideally by passing a property to "gradle run"?
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"
Instead of deploying my app to
http://localhost:8080/myApp
I want to deploy it to
http://localhost
To change the run-app port, edit grails-app/conf/BuildConfig.groovy and add the line
grails.server.port.http = 80
To remove the context (the 'myApp' part) edit application.properties and add the line
app.context=/
deploy your app to a tomcat server with the war name as ROOT.war.
Because war names describe contexts... papa.war will be available through [root_domain]/papa
To remove the port, use:
grails -Dserver.port=80 run-app