cli icon indicating copy to clipboard operation
cli copied to clipboard

Heroku Local server doesn't close

Open georgeedwards opened this issue 8 years ago • 4 comments

This project is for the Heroku CLI only. Use https://help.heroku.com for anything that is not specific to the CLI itself.

Do you want to request a feature or report a bug?

bug

What is the current behavior?

I followed the getting started turotial - i.e. clone the git repo, setup the heroku cli etc.

  1. I then run heroku local web
  2. Everything works as expected
  3. Run ctrl + c to end the process
  4. Appears to work
  5. Try to run heroku local web again and get error. Server never stopped.

see:

C:\Users\GeorgeEdwards\node-js-getting-started>heroku local web
[OKAY] Loaded ENV .env File as KEY=VALUE Format
8:49:07 PM web.1 |  Listening on 5000
[WARN] Interrupted by User
^CTerminate batch job (Y/N)? Y

C:\Users\GeorgeEdwards\node-js-getting-started>heroku local web
events.js:167
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE :::5000
    at Server.setupListenHandle [as _listen2] (net.js:1286:14)
    at listenInCluster (net.js:1334:12)
    at Server.listen (net.js:1421:7)
    at Function.listen (C:\Users\GeorgeEdwards\node-js-getting-started\node_modules\express\lib\application.js:618:24)
    at Object.<anonymous> (C:\Users\GeorgeEdwards\node-js-getting-started\index.js:12:4)
    at Module._compile (internal/modules/cjs/loader.js:688:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
    at Module.load (internal/modules/cjs/loader.js:598:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
    at Function.Module._load (internal/modules/cjs/loader.js:529:3)
Emitted 'error' event at:
    at emitErrorNT (net.js:1313:8)
    at process._tickCallback (internal/process/next_tick.js:63:19)
    at Function.Module.runMain (internal/modules/cjs/loader.js:744:11)
    at startup (internal/bootstrap/node.js:285:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)

What is the expected behavior?

The local server to close after the ctrl +c is pressed twice and then be free to restart at a later date. >heroku --version heroku/7.18.10 win32-x64 node-v11.1.0

georgeedwards avatar Nov 30 '18 20:11 georgeedwards

When using Windows CMD you can work around this by freeing up the port with the following commands. My example assumes you're using Port 8080

netstat -ano | findstr :8080

The output may vary, but you should see ports matching :8080 currently open with the last number being the PID (Process Identification)

  TCP    0.0.0.0:8080           0.0.0.0:0              LISTENING       7984
  TCP    [::]:8080              [::]:0                 LISTENING       7984

Based on that PID you then run the following command to forcefully close the process

taskkill /PID 7984 /F

zo103181 avatar Dec 11 '18 15:12 zo103181

Appears this was corrected for my setup with the following CLI version:

heroku/7.19.4 win32-x64 node-v11.3.0

zo103181 avatar Jan 29 '19 16:01 zo103181

I know this is an old ticket but this still happens all the time with 7.69.1

Is there any way we can get the heroku local to close the server?

armordog avatar Mar 09 '23 23:03 armordog

Thank you for letting us know, we'll take a look into it.

GUS item

k80bowman avatar Mar 13 '23 13:03 k80bowman