Have you read the Contributing Guidelines on issues?
Prerequisites
Description
On macOS, consider the following script server.js:
const http = require("http");
const port = 3000;
const requestListener = function (req, res) {
res.writeHead(200);
res.end("My first server!");
};
const server = http.createServer(requestListener);
server.listen(port, () => {
console.log(`Server is running on http://localhost:${port}`);
});
Run it using node server.js.
Then start a Docusaurus project (running on v2.1.0 in my case). The documentation server will start on port 3000, although it is busy. If you then open Docusaurus in Chrome:

it opens my server.
however, if I use curl, I get the docusaurus page!

If my server passes a host:
- server.listen(port, () => {
+ server.listen(port, "localhost", () => {
then Docusaurus will correctly identify that the port is busy and asks if I want to choose another port. Nonetheless I see it as a bug in Docusaurus or one of it's dependencies.
Possible solution
Although used by less people, this logic for finding a free port works now in Remotion without bug reports coming in: https://github.com/remotion-dev/remotion/blob/main/packages/renderer/src/get-port.ts
I am happy to chat on Discord how to investigate it together!
Reproducible demo
No response
Steps to reproduce
As above
Expected behavior
Busy port detection kicks in and asks if a different port should be used
Actual behavior
Server gets started and a conflict is created
Your environment
- Docusaurus version used: v2.1.0
- Environment name and version (e.g. Chrome 89, Node.js 16.4): Node 16.7
- Operating system and version (e.g. Ubuntu 20.04.2 LTS): macOS
Self-service
Have you read the Contributing Guidelines on issues?
Prerequisites
npm run clearoryarn clearcommand.rm -rf node_modules yarn.lock package-lock.jsonand re-installing packages.Description
On macOS, consider the following script
server.js:Run it using
node server.js.Then start a Docusaurus project (running on v2.1.0 in my case). The documentation server will start on port 3000, although it is busy. If you then open Docusaurus in Chrome:

it opens my server.however, if I use curl, I get the docusaurus page!
If my server passes a host:
then Docusaurus will correctly identify that the port is busy and asks if I want to choose another port. Nonetheless I see it as a bug in Docusaurus or one of it's dependencies.
Possible solution
Although used by less people, this logic for finding a free port works now in Remotion without bug reports coming in: https://github.com/remotion-dev/remotion/blob/main/packages/renderer/src/get-port.ts
I am happy to chat on Discord how to investigate it together!
Reproducible demo
No response
Steps to reproduce
As above
Expected behavior
Busy port detection kicks in and asks if a different port should be used
Actual behavior
Server gets started and a conflict is created
Your environment
Self-service