Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Requested port is not assigned after 5.0.0 update, even though its available #43

mikemykhaylov opened this issue Jan 2, 2020 · 3 comments


Copy link

mikemykhaylov commented Jan 2, 2020


I have an issue. The code is:


const getPort = require('get-port');
const {spawn} = require('child_process');
const processExists = require('process-exists');
const delay = require('delay')
const fkill = require('fkill');

async function test() {
  const port = await getPort();
  const {pid} = spawn('node', ['fixture.js', port]);
  console.log(`Process exists with PID: ${pid}: ${await processExists(pid)}`);
  await fkill(pid);
  await delay(100);
  console.log(`Process exists with PID: ${pid}: ${await processExists(pid)}`);
	if(!await processExists(pid)) {
    const samePort = await getPort({port});
  } else {
    console.log('Process not killed');



'use strict';
const http = require('http');

const server = http.createServer((request, response) => {


With version 4.2.0 the output is as expected

Process exists with PID: 15767: true
Process exists with PID: 15767: false

With ^5.0.0, however, the second time I'm requesting the port, it comes out 1 more than before:

Process exists with PID: 15945: true
Process exists with PID: 15945: false

Has anyone here encountered this issue or knows any way to solve it?

Copy link

sindresorhus commented Jan 15, 2020

// @davidmarkclements

hacdias referenced this issue in ipfs/ipfs-desktop Apr 18, 2020
License: MIT
Signed-off-by: Henrique Dias <>
jan-molak added a commit to serenity-js/serenity-js that referenced this issue Jul 4, 2020
… on a random port after restart

Replaced get-port with portfinder to avoid issue sindresorhus/get-port#43
Copy link

mikemykhaylov commented Nov 20, 2020

The package seems to be abandoned, closing the issue. Use portfinder for similar functionality

Copy link

sindresorhus commented Nov 20, 2020

Not abandoned, just lack of time on my part.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

2 participants