Fix HPE_INVALID_METHOD Error in Node.JS (Hapi/Fastify/Express)

When You’re Making HTTP request in Node.JS Server Written In Node.JS Rest API Frameworks such Express.js, Hapi.js, Fastify.js and Many more, Suddenly, you encounter error “parse Error: Invalid method encountered”, “stack”: Error: Parse Error: Invalid method encountered “bytesParsed”: 0, “code”: “HPE_INVALID_METHOD””, Don’t Panic it’s very not any programming mistake, rather simple typo mistake.

Fix:
What you’re trying to do is, trying to access `https://` instead of http:// . Go Ahead try it, it will work.

Thanks stackoverflow user for solution Roman.

See also  How to run shell script file or command using Nodejs?

Leave a Comment