Reputation:
OSX 10.11 I installed the latest nginx 1.9.9 (from source and compiled ) the configuration file /usr/local/conf/nginx.conf syntax is ok
when listening on port 8080 no problem I can request http://example.local:8080
server {
listen 8080;
server_name example.local;
root HTML;
And then run:
sudo lsof -i -P | grep -i "80"
nginx 8254 root 10u IPv4 0x643a3abbad7bf485 0t0 TCP *:8080 (LISTEN)
nginx 8392 yves 10u IPv4 0x643a3abbad7bf485 0t0 TCP *:8080 (LISTEN)
BUT when I change the port to 80, I cannot reach http://example.local:80
server {
listen 80;
server_name example.local;
root html;
sudo nginx -s reload
nginx 8254 root 10u IPv4 0x643a3abbad7bf485 0t0 TCP *:8080 (LISTEN)
nginx 8254 root 18u IPv4 0x643a3abbadbb9485 0t0 TCP *:80 (LISTEN)
nginx 8430 yves 10u IPv4 0x643a3abbad7bf485 0t0 TCP *:8080 (LISTEN)
nginx 8430 yves 18u IPv4 0x643a3abbadbb9485 0t0 TCP *:80 (LISTEN)
Safari canot open the page however I can still request http://example.local:8080
very weird .... Nginx IS LISTENING on 80 ... what can I do ?
Upvotes: 10
Views: 15734
Reputation: 11
Run top in your the terminal and use F3 to search for the NGINX process.
Copy the PID number from the running NGINX process when you find in the top list running process.
Paste the PID number into /usr/local/nginx/logs/nginx.pid
.
Just paste in the PID number on it's own on the first line of the nginx.pid
file.
Even if already stopped it before STOP nginx sudo nginx -s stop
and then start it again sudo nginx
.
Nginx can't stop it's process because it doesn't know the PID number and the running instance is bound to the relative port blocking a second instances binding to the same port.
This was on MacOS Ventura, a fresh install. It happened because I changed the location of the PID file in the NGINX config file while it was running and therefore it couldn't stop itself.
Upvotes: 0
Reputation: 774
Check firwall or iptables.
Port 80 might be blocked. Try stopping firewall or iptables service.
If it is blocked, then add entry to allow port 80
Upvotes: 0
Reputation: 416
You just can run services on ports below to 1024 as sudo.
Running on the go:
$ sudo brew services restart nginx
Starting with the system:
$ sudo cp /usr/local/opt/nginx/*.plist /Library/LaunchDaemons
$ sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
Note that you must set up your server to listen to 80 inside your config file and make sure there's no other process running at port 80.
Upvotes: 15