Unable to kill process Ubuntu 14.04 - ubuntu-14.04

I am trying to kill processes on port 80. Here are the process running on port 80
lsof -i tcp:80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 6233 root 13u IPv4 4216925 0t0 TCP *:http (LISTEN)
nginx 6235 opscode 13u IPv4 4216925 0t0 TCP *:http (LISTEN)
I have tried killing processes using kill -9 <PID> but they still exist with PID changed. How can I kill the processes forcefully?

Your question is better suited on serverfault.com or askubuntu.com.
But I think your problem is that you have an nginx daemon started.
You can stop it with either systemctl stop nginx if you are using systemd or service nginx stop if you are using system V

Related

open a port owned by root on linux?

I am currently working with docker, the image of my container is on port 49161, however, the port was occupied by another process. So I killed this process by doing sudo kill PID in order to free the port. Nevertheless, now the port seems to be occupied by a PID belonging to the root. Is it possible to free this port (49161) ?
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
findmydev 267 root 4u IPv6 0xcf3f933fd8e68451 0t0 TCP [fe80:4::aede:48ff:fe00:1122]:49161->[fe80:4::aede:48ff:fe33:4455]:49169 (ESTABLISHED)
try this out
pgrep -u root [processID]

Socket files not closed by Node process

I am facing a strange issue with our node service.
Lots of socket file descriptors have remained open against node process and limit for open files (10240 files) against process has reached. So, I am getting EMFILE error.
Service has stalled and stopped accepting new requests as well as sending outbound requests to other services.
Nowhere in code I am EXPLICITLY dealing with socket connections.
Node process still listening on port. We are using PM2.
Similar question for Java: https://serverfault.com/questions/153983/sockets-found-by-lsof-but-not-by-netstat
Below is details of versions:
Node version: 8.16.0
Hapi: 14.2.0
request: 2.88.2 (used to send
outbound requests)
Commands output in console:
[CONSOLE ~]$ lsof -p [PID] | wc -l
10253
[CONSOLE ~]$ ulimit -a
.
.
file size (blocks, -f) unlimited
.
.
max memory size (kbytes, -m) unlimited
open files (-n) 10240
.
.
.
[CONSOLE ~]$ netstat -np | grep [PORT]
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
[CONSOLE ~]$ netstat -a -n | grep [PORT]
tcp 0 0 0.0.0.0:[PORT] 0.0.0.0:* LISTEN
[CONSOLE ~]$ lsof -i :[PORT]
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
node [PID] glpd 15u IPv4 2270823542 0t0 TCP *:[PORT] (LISTEN)
[CONSOLE ~]$ lsof -p [PID]
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
.
.
.
node [PID] glpd 15u IPv4 2270823542 0t0 TCP *:[PORT] (LISTEN)
node [PID] glpd 16u sock 0,7 0t0 2271652082 protocol: TCP
node [PID] glpd 17u sock 0,7 0t0 2271551621 protocol: TCP
node [PID] glpd 18u sock 0,7 0t0 2271663118 protocol: TCP
node [PID] glpd 19u sock 0,7 0t0 2271662963 protocol: TCP
node [PID] glpd 20u sock 0,7 0t0 2271660595 protocol: TCP
node [PID] glpd 21u sock 0,7 0t0 2271652144 protocol: TCP
node [PID] glpd 22u sock 0,7 0t0 2271660631 protocol: TCP
node [PID] glpd 23u sock 0,7 0t0 2271662997 protocol: TCP
node [PID] glpd 24u sock 0,7 0t0 2271660660 protocol: TCP
node [PID] glpd 25u sock 0,7 0t0 2271663083 protocol: TCP
.
.
.
Has anyone come across this in Node?
EDIT:
Socket timeout for all incoming requests to this service are disabled(set to false) as it is our main processing service and we can not predict the amount of time a request can take to get processed.
I had the same problem. In my case nodemailer did not close the connection after transport.close(). Updating to the latest nodemailer version solved the problem.

SSH server - Get pid of sshd process forwarding port #N

I'm running a server (Ubuntu Server 14.04) which allows the clients to make a ssh tunnel from their device (Raspberry Pi) so they can access their web server from the internet (as a mean to traverse NATs). I can get a list of processes owned by the user (which is the same for all the devices) using ps -u username (this user only runs sshd to forward ports), but I can't filter those processes by the port they're forwarding. So the question is, how can I get the pid of the sshd that is forwarding port #N?
You can make use of lsof command since everything is a file on linux.
Something like lsof -Pan -i | grep :PORT will get you what you ask. It has an output like this when i run it for port 80 on my machine:
Command PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 1104 root 6u IPv4 23348 0t0 TCP *:80 (LISTEN)
nginx 1105 www-data 6u IPv4 23348 0t0 TCP *:80 (LISTEN)
nginx 1106 www-data 6u IPv4 23348 0t0 TCP *:80 (LISTEN)
nginx 1107 www-data 6u IPv4 23348 0t0 TCP *:80 (LISTEN)
nginx 1108 www-data 6u IPv4 23348 0t0 TCP *:80 (LISTEN)
More on lsof can be found here

weird situation for nanomsg and linux

It's very strange.
I write a message distribute server upon nanomsg.
But after some time,when i restart the server, i failed because the listening port has been used.
Here is the situation:
[root#vsmHost12 src]# lsof -n -i:3333
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
hsmcs 105013 root **20u** IPv4 **24845821** 0t0 TCP :dec-notes (LISTEN)
hsmcs 105013 root 66u IPv4 25366582 0t0 TCP 192.168.167.1:dec-notes->192.168.167.1:47826 (ESTABLISHED)
java 111946 root **20u** IPv4 **24845821** 0t0 TCP *:dec-notes (LISTEN)
java 111946 root 34u IPv6 25366581 0t0 TCP 192.168.167.1:47826->192.168.167.1:dec-notes (ESTABLISHED)
It's not because of the java, some other daemon may also have the problem.
Look at the FD number and DEVICE number, it's the SAME!
Can anyone explain it ?

What is the opposite of mod_wsgi-express start-server

I accidentally closed the terminal after running this command
mod_wsgi-express start-server
And I can't find the resource on how to stop the server
What is the command?
I had run the mod_wsgi-express script on a virtual environment on port 5000.I had to run the following command to stop it.
/tmp/mod_wsgi-localhost:5000:1002/apachectl stop
The solution
I opened terminal and killed the process via the pid
I opened the terminal and ran the following code to get the pid of the process
lsof -i -f
This is a sample response I got
apache2 20000 ebrahim 3u IPv4 1234565 0t0 TCP *:8000 (LISTEN)
apache2 20001 ebrahim 3u IPv4 1234565 0t0 TCP *:8000 (LISTEN)
apache2 20004 ebrahim 3u IPv4 1234565 0t0 TCP *:8000 (LISTEN)
Then I performed the following command to kill it in the form of sudo kill (pid number) for example
sudo kill 20000
Another way (more proper way) to do this is to go to the to the directory that holds the apachectl file. (the directory changes if you use the --server-root option when using the mod_wsgi-express start server command).
You simply have to run the code below from terminal
/etc/mod_wsgi-express-80/apachectl stop

Resources