Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Express server causes error "This site can’t provide a secure connection localhost sent an invalid response"

I'm trying to make a simple hello world kind of server using Express. Here goes my code:

const express = require("express");
const app = express();

app.get("/",function(request, response){//what to do when someone make get request to the homepage or route
  console.log(request);
  response.send("hello");
});

app.listen(3000, function(){
  console.log("server is listening at port 3000");
});

When I run the program I see this at the command prompt:

server is listening at port 3000

But when I'm accessing it through a browser i.e. https://localhost:3000, I'm getting an error:

This site can’t provide a secure connection localhost sent an invalid response. Try running Windows Network Diagnostics. ERR_SSL_PROTOCOL_ERROR

I expect the browser to see hello as per my method, above, response.send("hello")

like image 929
mudassir ahmed Avatar asked Dec 06 '22 09:12

mudassir ahmed


1 Answers

You need to access it through the HTTP protocol instead. try to connect to http://localhost:3000 instead of https://localhost:3000.

like image 188
fishcakes Avatar answered May 17 '23 15:05

fishcakes