{"id":3140,"date":"2020-04-08T15:47:16","date_gmt":"2020-04-08T14:47:16","guid":{"rendered":"https:\/\/www.itersdesktop.com\/?p=3140"},"modified":"2020-04-10T16:34:58","modified_gmt":"2020-04-10T15:34:58","slug":"how-to-change-default-server-port-for-grails-application","status":"publish","type":"post","link":"https:\/\/www.itersdesktop.com\/fr\/2020\/04\/08\/how-to-change-default-server-port-for-grails-application\/","title":{"rendered":"How to change default server port for Grails application"},"content":{"rendered":"\n<p>As a web developer, all of us are aware of the number <code>8080<\/code> as the holy port nobody can forget. In Grails based applications, there is no exception at all.<\/p>\n\n\n\n<p>For some reasons, we might need to run multiple grails application on our laptop. In this situation, knowing how to change the default port of grails application would be valuable.<\/p>\n\n\n\n<p>In this post, I will show you how to obtain the purpose by doing few steps below.<\/p>\n\n\n\n<p><strong>Prior to grails 3.x<\/strong>, we can change the port by running the application using following command:<\/p>\n\n\n\n<p><code>grails -Dserver.port=8181 run-app<\/code><\/p>\n\n\n\n<p>This command sets the given port temporarily. You have to use this command each time when you run the application from the terminal or console.<br \/>If you want to change port permanently, i.e., the application by default runs on other port than 8080, you can easily fix the port number by adding following line in your&nbsp;<strong>BuildConfig.groovy<\/strong>&nbsp;file:<\/p>\n\n\n\n<p><code>grails.server.port.http=8181<\/code><\/p>\n\n\n\n<p>A few years ago, <strong>grails 3.x<\/strong>&nbsp;was released and they have changed the way of changing the default port. This is right to grails 4.x though there are lots of changed and improved.<\/p>\n\n\n\n<p><strong>For Temporary change<\/strong><br \/>Run the application using following command from the terminal where the project locates:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">SERVER_PORT=8181 grails run-app<\/pre>\n\n\n\n<p><strong>For Permanent change<\/strong><br \/>Add following line in your&nbsp;<strong>application.yml<\/strong>&nbsp;file<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">server:\n   port:\n      8181\n<\/pre>\n\n\n\n<p>Or, add the following line in your <strong>application.groovy<\/strong> file<br \/><code>server.port=8181<\/code><\/p>\n\n\n\n<p>Hopefully, these tricks would bring a convenient way for you to change the server port of your Grails applications.<\/p>\n\n\n\n<p>All constructive comments are welcomed. If you are willing to contribute financial support for our website, please follow the instructions below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As a web developer, all of us are aware of the number 8080 as the holy port nobody can forget. In Grails based applications, there is no exception at all.&hellip; <\/p>\n","protected":false},"author":2,"featured_media":3142,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[593,4,222],"tags":[672,691,692,673],"class_list":["post-3140","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-grails","category-web-engineering","category-web-programming","tag-change-port","tag-change-server-port","tag-default-port","tag-port"],"_links":{"self":[{"href":"https:\/\/www.itersdesktop.com\/fr\/wp-json\/wp\/v2\/posts\/3140","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.itersdesktop.com\/fr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.itersdesktop.com\/fr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.itersdesktop.com\/fr\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.itersdesktop.com\/fr\/wp-json\/wp\/v2\/comments?post=3140"}],"version-history":[{"count":9,"href":"https:\/\/www.itersdesktop.com\/fr\/wp-json\/wp\/v2\/posts\/3140\/revisions"}],"predecessor-version":[{"id":3161,"href":"https:\/\/www.itersdesktop.com\/fr\/wp-json\/wp\/v2\/posts\/3140\/revisions\/3161"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.itersdesktop.com\/fr\/wp-json\/wp\/v2\/media\/3142"}],"wp:attachment":[{"href":"https:\/\/www.itersdesktop.com\/fr\/wp-json\/wp\/v2\/media?parent=3140"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.itersdesktop.com\/fr\/wp-json\/wp\/v2\/categories?post=3140"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.itersdesktop.com\/fr\/wp-json\/wp\/v2\/tags?post=3140"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}