I am using Nginx to run both the frontend and backend from the same PC.
Frontend: React (localhost:3000)
Backend : GO-Lang (localhost:8080)
You can expect CORS error when you try to access BE APIs from your FE code.
To overcome this I used nginx to create proxies for FE and BE on Different routes but on the same port (localhost:8000)
FE: /
BE: /server
nginx.conf
upstream server {
server localhost:8080;
}
upstream client {
server localhost:3000;
}
server {
listen 8000;
server_name localhost;
location / {
proxy_pass http://client;
}
location ~ /server/(?<section>.*) {
rewrite ^/server/(.*)$ /$1 break;
proxy_pass http://server;
}
}
I stopped the nginx with sudo nginx -s stop
Closed terminal
Quit terminal completely
But didn't shut down my PC
Today I tried some other configs with the same port (8000) and got the error mentioned in the title.
So used a different port everything worked as expected.
But when I reverted my config to the above config again. It is showing the error mentioned in the title.
The problem
What I observed is all the ports I used in step 2 are occupied now and I am not able to use them although I have stopped all the servers earlier.
After reverting back to the initial config even though the port I am trying to use is 8000 it still says that the port is occupied.
How can I use my port 8000 again?