Welcome to the Linux Foundation Forum!

Lab 3.2

Hi, I am having some minor issues with the validate.js on the lab 3.2

I tested my code using postman and I get the expected responses for the given cases, but when I run the validate.js I still get one error:

⛔️ POST http://localhost:3000/ must respond with 405 Method Not Allowed status

const express = require('express');
const app = express();
const http = require('http')
const server = http.createServer(app);
const createError = require('http-errors');

const port = 3000

app.use((req, res, next) => {
if (req.method !== 'GET') {
return next(createError(405))
if (req.path !== '/') {
return next(createError(404))

app.use((err, req, res, next) => {
res.status(err.status || 500)

app.get("/", (req, res) => {
res.status(200).send("Hello World")

server.listen(port, () => {
console.log(Server listening on port ${port});

What am I missing?


  • @ewertonazevedo I've run your code locally and it validates just fine. It's possible you had a zombie node process occupying the port that you were unaware of, I think if you try this again it should work.


Upcoming Training