Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access to localhost was denied You don't have authorization to view this page. HTTP ERROR 403

I have a little NodeExpress server and when I try to make a request to the server it returns a 403 error I have installed Cors and used it and tried with chrome browser and Postman as 2 clients and got the same denied error

var express = require('express')
var cors = require('cors')
var app = express()

app.use(cors())

app.get('/', function (req, res, next) {
  res.json({msg: 'This is CORS-enabled for all origins!'})
})

app.listen(80, function () {
  console.log('CORS-enabled web server listening on port 80')
})
like image 295
Yusuf Avatar asked Dec 06 '25 06:12

Yusuf


1 Answers

I was having this having this problem with using firebase serve on MacBook Pro (14-inch, 2021), Apple M1 Pro, macOS Monterey 12.3

UPDATE:

so apparently the reason was

macOS Monterey introduced AirPlay Receiver running on port 5000. This prevents your web server from serving on port 5000. Receiver already has the port.

so the solution proposed by the answer quoted above, was to either turn off the AirPlay Receiver, or to run your app on another port.

if you are running your app using firebase serve, You can change the port by following this approach:

source

firebase.json file doesn't work with the the firebase serve command. You have to use the firebase emulators:start command.

If you want to keep using firebase serve then it should be use like in:

firebase serve --only hosting --port=5002

OLD ANSWER:

Not a sufficient answer, but I was able to bypass this by entering 127.0.0.1 instead of localhost. I don't think this is the best answer, neither I am satisfied with it. I'll definitely come back later and update the answer once I find a better answer.

like image 191
Adnan Avatar answered Dec 07 '25 21:12

Adnan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!