2

I'm running a node.js webserver on an Amazon Linux EC2, but I can't listen on port 80 because there's an nginx server listening on that port:

[ec2-user@ip-172-31-39-178 server]$ sudo netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name
tcp        0      0 127.0.0.1:6666              0.0.0.0:*                   LISTEN      934/pm2
tcp        0      0 127.0.0.1:6667              0.0.0.0:*                   LISTEN      934/pm2
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      27324/nginx
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      1211/sshd
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      1251/sendmail
tcp        0      0 :::22                       :::*                        LISTEN      1211/sshd
udp        0      0 0.0.0.0:68                  0.0.0.0:*                               971/dhclient
udp        0      0 172.31.39.178:123           0.0.0.0:*                               1236/ntpd
udp        0      0 127.0.0.1:123               0.0.0.0:*                               1236/ntpd
udp        0      0 0.0.0.0:123                 0.0.0.0:*                               1236/ntpd
[ec2-user@ip-172-31-39-178 server]$

I don't know if I should just delete nginx (Not sure where to find it, if I were to try), or turn it off, or something like that. I don't use an nginx web-server, I guess it came packaged with the Amazon EC2.

I tried this, but it didn't work:

 sudo rm -f -R /usr/local/nginx && rm -f /usr/local/sbin/nginx
3

I will say right from the start I do not know Amazon Linux EC2, but I did do a bit of research to try and help.

You should be able to stop nginx with:

nginx -s stop

You should be able to stop it from starting on reboot with:

chkconfig nginx off

It may be that you need to use sudo to issue both of these commands:

sudo nginx -s stop

sudo chkconfig nginx off

It may be that you need to use the path:

sudo /etc/init.d/nginx stop

sudo /sbin/chkconfig nginx off

I cannot tell you this is the right path, however, this is what I found. If this does not seem to be the right path, you can always use find. You may need to use man find for specifics.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.