G dangi
G dangi

Reputation: 188

Grails project run error -Server failed to start for port 8080: Address already in use: JVM_Bind

Error | Server failed to start for port 8080: Address already in use: JVM_Bind (Use --stacktrace to see the full trace)

When I going to execute my grails project second time using --- 2 Grails Command(run-app) struck with this type of error each and every time.

But when I kill the javaw.exe using Task Manager then if I will run again it works for me. Is there any permanent solution for this?..pls suggest.

|Packaging Grails application ..

|Compiling 10 source files ..

|Compiling 121 source files .......

|Compiling 9 source files .........................

|Running Grails application

Error | Server failed to start for port 8080: Address already in use: JVM_Bind (Use --stacktrace to see the full trace)

Upvotes: 2

Views: 8728

Answers (5)

HARSH SHAH
HARSH SHAH

Reputation: 1

following these below steps

1)Go to command line

2)if you use current port 8080 or whatever port you use ->example--->use below command

sudo lsof -i tcp:8080

->example--->if you use current port 3000

sudo lsof -i tcp:3000

3)Then you can see your PID or process id

kill -9 {process_id} or `kill -9 {pId}`

-> example--->suppose your PID is 22345 then use

kill -9 22345 

4)Now rerun your project this will be working 110%

Upvotes: 0

007
007

Reputation: 161

Open BuildConfig.groovy

Solution 1 : then replace this line with run:false run: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false],

Solution 2 : comment Previous line

Upvotes: 0

Ted Delezene
Ted Delezene

Reputation: 2481

When you run the app for the first time, it will continue to run until you explicitly tell it to stop. Regardless of how you start the app (whether it be from GGTS or command prompt) until you send the command stop-app it will continue. You get the error you have been encountering:

Error | Server failed to start for port 8080: Address already in use: JVM_Bind (Use --stacktrace to see the full trace)

when that server is still running. Grails will compile your changes as you make them, and you are able to see the results on your web page right away (for most changes, making changes to your domain objects can be problematic, and often will require you restart your server).

Personally I prefer to edit the project in GGTS but use a console to manage the app simply because I prefer the error output from the console instead of GGTS.

Upvotes: 3

dmahapatro
dmahapatro

Reputation: 50275

With latest version of Grails (from 2.3.0), default setting is to run the server in forked mode. You can find this config in BuildConfig.groovy:

grails.project.fork = [ ... ]

With the above forked mode enabled for run-app, app has to be stopped explicitly before re-run. Therefore, grails stop-app has to be issued before grails run-app.

If you do not want to run app in forked mode, then replace this line with run:false:

run: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false]

With that, there will not be a need to explicitly run the stop-app command.

Upvotes: 1

Abincepto
Abincepto

Reputation: 1036

You can specify the HTTP port to run the server using the cli:

Example:

grails -Dserver.port=8090 run-app

More details in the documentation

Upvotes: 5

Related Questions