I’m trying to host a small HTTP server on Glitch. The code currently is…
const http = require("http");
const server = http.createServer((req, res) => {
res.writeHead(200, {
"Content-Type": "text/plain"
});
res.end("Hello, world!");
});
server.on("listen", () => { console.log("\x1b[1mLISTENING\x1b[0m") }); // Logs "LISTENING" in bold
server.listen(3000); // 3000 is used as that is what another post said to do. I've also tried 80, 443, 4040, 8000, and 8080
My package.json is…
{
"name": "my project name",
"version": "1.0.0",
"description": "",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"http": "^0.0.0"
}
}
When I run node .
in the terminal, it says address already in use :::3000
. Is there a specific port I should use when running server.js?