0

I am using Code Server within my Cloud Shell. I need to use the port 3000 for a specific npm package. Unfortunately port 3000 is already used by the default editor Theia within Cloud Shell.

I have already tried the following:

  • sudo kill {{PID of Theia process}} ...but it restarts again immediatelly
  • searched for settings within /google/devshell/editor/theia ...but could not find any port settings

sudo netstat -tlnp gives the following output: enter image description here

Any help is very appreciated.

JShinigami
  • 7,317
  • 3
  • 14
  • 22

2 Answers2

0

As mentioned by JShinigami, That issue got resolved here by changing the port of the other application, other alternative of resolving this issue is as below :

First I would recommend you to reset your cloud shell.

You can refer to the Answer to follow the steps on how to kill a process running on the particular Port.

Option 1 A One-liner to kill only LISTEN on specific port:

kill -9 $(lsof -t -i:3000 -sTCP:LISTEN)`

Option 2 If you have npm installed you can also run

npx kill-port 3000

I also found this answer on stack overflow that may be relevant as it shows how they were able to kill the process once they obtained its PID.

could you run the following command :

"sudo netstat -tlnp"

From the above you will be able to tell what processes are running on the ports. From there you will see the Possibility of "auto restart" configuration somewhere causing the process to appear even after kill command.

Found this useful article on ways to list processes running on ports.

Divyani Yadav
  • 1,030
  • 4
  • 9
  • Thank you for your answer. 1) The first option does not execute 2) The second option does not kill any process, if I do a check afterwards via "fuser 3000/tcp" I can still see the process running 3) I have killed all listed processes, but the one listening on port 3000 is restarted again. There are two PIDs mainly involved I guess, /node and /theia-proxy. /node is using port 3000 and I assume it is restarted by /theia-proxy. The strange thing is that the /theia-proxy process changes it's PID on its own, each couple of seconds it has another PID. Any further ideas? – JShinigami Sep 13 '22 at 05:04
  • @JShinigami have you tried restarting the cloud shell? can you run this command : "sudo netstat -tlnp" and can you share the output too?? – Divyani Yadav Sep 15 '22 at 09:28
  • Yes I have restarted the cloud shell. Please find the output of the netstat command within the initial question post at the top. Thanks – JShinigami Sep 16 '22 at 10:17
  • can you try fuser -k 3000/tcp ? and after you killed and restarted the cloud shell still its running? – Divyani Yadav Sep 20 '22 at 09:44
  • also refer this [issue_1](https://unix.stackexchange.com/q/333373) and [issue_2](https://unix.stackexchange.com/q/158194). – Divyani Yadav Sep 20 '22 at 09:47
  • Thank you for your efforts, I have found another solution for my issue. – JShinigami Sep 21 '22 at 06:04
  • @JShinigami can you post your answer here? – Divyani Yadav Sep 21 '22 at 06:24
  • I could change the port of the other application, this was easier. – JShinigami Sep 22 '22 at 07:04
  • @JShinigami edited my answer by adding your alternative method in it , have a look. – Divyani Yadav Sep 23 '22 at 07:34
0

This is cloudshelledit occupy the port If you don't need cloudshelledit and can kill off And if you open the cloudshelledit, this process is not shut off

cloudshelledit

马治武
  • 1
  • 1
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 25 '22 at 07:04