How to close or (unbind?) a port left open by a rogue application?












16















I am using Fedora 13 64bit. My eclipse program starts a server on port 9050 but I shutdown the program, eclipse fails to properly shutdown the server. Restarting eclipse has no effect.



How can I close or unbind a port forcibly from command line?



I know rebooting or log off and back on will clear the ports but this much slower process for me. I am looking for forcibly closing the port in command line.










share|improve this question





























    16















    I am using Fedora 13 64bit. My eclipse program starts a server on port 9050 but I shutdown the program, eclipse fails to properly shutdown the server. Restarting eclipse has no effect.



    How can I close or unbind a port forcibly from command line?



    I know rebooting or log off and back on will clear the ports but this much slower process for me. I am looking for forcibly closing the port in command line.










    share|improve this question



























      16












      16








      16


      3






      I am using Fedora 13 64bit. My eclipse program starts a server on port 9050 but I shutdown the program, eclipse fails to properly shutdown the server. Restarting eclipse has no effect.



      How can I close or unbind a port forcibly from command line?



      I know rebooting or log off and back on will clear the ports but this much slower process for me. I am looking for forcibly closing the port in command line.










      share|improve this question
















      I am using Fedora 13 64bit. My eclipse program starts a server on port 9050 but I shutdown the program, eclipse fails to properly shutdown the server. Restarting eclipse has no effect.



      How can I close or unbind a port forcibly from command line?



      I know rebooting or log off and back on will clear the ports but this much slower process for me. I am looking for forcibly closing the port in command line.







      linux fedora






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jul 7 '11 at 12:12







      Mark

















      asked Jul 7 '11 at 12:05









      MarkMark

      142128




      142128






















          4 Answers
          4






          active

          oldest

          votes


















          6














          The only way to forcefully close a listening port is to kill the process that is listening on it. Use lsof, netstat, fuser – as root – to find out the process ID. Once the process exits (by itself or by being killed), the kernel will automatically clean up all sockets it had open. (However, there might be cases that programs will be denied listening on the same port for a few minutes; in this case all you can do is wait.)






          share|improve this answer































            16














            lsof -n -i


            Find the process you're looking for and kill it.



            From lsof manual:




            -n This option inhibits the conversion of network numbers to host names for network files. Inhibiting conversion may make lsof run faster. It is also useful when host name lookup is not working properly.



            -i [i] This option selects the listing of files any of whose Internet address matches the address specified in i. If no address is specified, this option selects the listing of all Internet and x.25 (HP-UX) network files.




            Same answer to this question I think.






            share|improve this answer





















            • 4





              Throw on | grep ":9050" (or whatever port number) to easily filter the output

              – isaacparrot
              Jun 10 '14 at 0:28



















            4














            You can user the fuser command with the -k switch.



            For example, to close port 111, you can do the following: fuser -k 111/tcp
            (this also saves you the hassle of find the ID of the process to kill it as fuser does in implicitly)



            Note that some processes restart automatically once closed. For that, you need to check each process's config file to come up with an appropriate workaround.






            share|improve this answer































              -3














              I had the same issue, just look for the process whicj is listening that port using cmd command on windows



              netstat -a -b


              then you can shut it down with tasks manager






              share|improve this answer



















              • 2





                Sorry, I downvoted. You mention "on Windows". The "-b" parameter to netstat, which shows executable names, is specific to Microsoft Windows. (Unix netstat variations may have similar functionality, but is typically not using that same parameter.) However, the question said "Fedora", so the asker of this question was looking for information about Fedora 13 64bit, a different operating system. netstat's man page for Fedora indicates that using -p shows the PID (which can be used to identify the executable's name).

                – TOOGAM
                Jul 2 '16 at 11:14








              • 1





                There are several mistakes in this answer. The answer contains a grammatical error which could have been avoided. The answer also is not applicable to Fedora, which is clearly mentioned, in the first sentence of the question. It isn't like the question didn't contain this information when this answer was submitted 30 minutes ago, the question has not been edited since July 2011, which nearly 5 years ago. So I am taking this answer for what it is, a "me too" answer, which very rarely actually helpful.

                – Ramhound
                Jul 2 '16 at 11:36













              Your Answer








              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "3"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f307624%2fhow-to-close-or-unbind-a-port-left-open-by-a-rogue-application%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              4 Answers
              4






              active

              oldest

              votes








              4 Answers
              4






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              6














              The only way to forcefully close a listening port is to kill the process that is listening on it. Use lsof, netstat, fuser – as root – to find out the process ID. Once the process exits (by itself or by being killed), the kernel will automatically clean up all sockets it had open. (However, there might be cases that programs will be denied listening on the same port for a few minutes; in this case all you can do is wait.)






              share|improve this answer




























                6














                The only way to forcefully close a listening port is to kill the process that is listening on it. Use lsof, netstat, fuser – as root – to find out the process ID. Once the process exits (by itself or by being killed), the kernel will automatically clean up all sockets it had open. (However, there might be cases that programs will be denied listening on the same port for a few minutes; in this case all you can do is wait.)






                share|improve this answer


























                  6












                  6








                  6







                  The only way to forcefully close a listening port is to kill the process that is listening on it. Use lsof, netstat, fuser – as root – to find out the process ID. Once the process exits (by itself or by being killed), the kernel will automatically clean up all sockets it had open. (However, there might be cases that programs will be denied listening on the same port for a few minutes; in this case all you can do is wait.)






                  share|improve this answer













                  The only way to forcefully close a listening port is to kill the process that is listening on it. Use lsof, netstat, fuser – as root – to find out the process ID. Once the process exits (by itself or by being killed), the kernel will automatically clean up all sockets it had open. (However, there might be cases that programs will be denied listening on the same port for a few minutes; in this case all you can do is wait.)







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jul 7 '11 at 12:21









                  grawitygrawity

                  234k36494549




                  234k36494549

























                      16














                      lsof -n -i


                      Find the process you're looking for and kill it.



                      From lsof manual:




                      -n This option inhibits the conversion of network numbers to host names for network files. Inhibiting conversion may make lsof run faster. It is also useful when host name lookup is not working properly.



                      -i [i] This option selects the listing of files any of whose Internet address matches the address specified in i. If no address is specified, this option selects the listing of all Internet and x.25 (HP-UX) network files.




                      Same answer to this question I think.






                      share|improve this answer





















                      • 4





                        Throw on | grep ":9050" (or whatever port number) to easily filter the output

                        – isaacparrot
                        Jun 10 '14 at 0:28
















                      16














                      lsof -n -i


                      Find the process you're looking for and kill it.



                      From lsof manual:




                      -n This option inhibits the conversion of network numbers to host names for network files. Inhibiting conversion may make lsof run faster. It is also useful when host name lookup is not working properly.



                      -i [i] This option selects the listing of files any of whose Internet address matches the address specified in i. If no address is specified, this option selects the listing of all Internet and x.25 (HP-UX) network files.




                      Same answer to this question I think.






                      share|improve this answer





















                      • 4





                        Throw on | grep ":9050" (or whatever port number) to easily filter the output

                        – isaacparrot
                        Jun 10 '14 at 0:28














                      16












                      16








                      16







                      lsof -n -i


                      Find the process you're looking for and kill it.



                      From lsof manual:




                      -n This option inhibits the conversion of network numbers to host names for network files. Inhibiting conversion may make lsof run faster. It is also useful when host name lookup is not working properly.



                      -i [i] This option selects the listing of files any of whose Internet address matches the address specified in i. If no address is specified, this option selects the listing of all Internet and x.25 (HP-UX) network files.




                      Same answer to this question I think.






                      share|improve this answer















                      lsof -n -i


                      Find the process you're looking for and kill it.



                      From lsof manual:




                      -n This option inhibits the conversion of network numbers to host names for network files. Inhibiting conversion may make lsof run faster. It is also useful when host name lookup is not working properly.



                      -i [i] This option selects the listing of files any of whose Internet address matches the address specified in i. If no address is specified, this option selects the listing of all Internet and x.25 (HP-UX) network files.




                      Same answer to this question I think.







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Dec 30 '18 at 3:40









                      Pablo Bianchi

                      18410




                      18410










                      answered Jul 22 '12 at 20:08









                      jonnyflashjonnyflash

                      356138




                      356138








                      • 4





                        Throw on | grep ":9050" (or whatever port number) to easily filter the output

                        – isaacparrot
                        Jun 10 '14 at 0:28














                      • 4





                        Throw on | grep ":9050" (or whatever port number) to easily filter the output

                        – isaacparrot
                        Jun 10 '14 at 0:28








                      4




                      4





                      Throw on | grep ":9050" (or whatever port number) to easily filter the output

                      – isaacparrot
                      Jun 10 '14 at 0:28





                      Throw on | grep ":9050" (or whatever port number) to easily filter the output

                      – isaacparrot
                      Jun 10 '14 at 0:28











                      4














                      You can user the fuser command with the -k switch.



                      For example, to close port 111, you can do the following: fuser -k 111/tcp
                      (this also saves you the hassle of find the ID of the process to kill it as fuser does in implicitly)



                      Note that some processes restart automatically once closed. For that, you need to check each process's config file to come up with an appropriate workaround.






                      share|improve this answer




























                        4














                        You can user the fuser command with the -k switch.



                        For example, to close port 111, you can do the following: fuser -k 111/tcp
                        (this also saves you the hassle of find the ID of the process to kill it as fuser does in implicitly)



                        Note that some processes restart automatically once closed. For that, you need to check each process's config file to come up with an appropriate workaround.






                        share|improve this answer


























                          4












                          4








                          4







                          You can user the fuser command with the -k switch.



                          For example, to close port 111, you can do the following: fuser -k 111/tcp
                          (this also saves you the hassle of find the ID of the process to kill it as fuser does in implicitly)



                          Note that some processes restart automatically once closed. For that, you need to check each process's config file to come up with an appropriate workaround.






                          share|improve this answer













                          You can user the fuser command with the -k switch.



                          For example, to close port 111, you can do the following: fuser -k 111/tcp
                          (this also saves you the hassle of find the ID of the process to kill it as fuser does in implicitly)



                          Note that some processes restart automatically once closed. For that, you need to check each process's config file to come up with an appropriate workaround.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Dec 2 '16 at 15:33









                          tony9099tony9099

                          223110




                          223110























                              -3














                              I had the same issue, just look for the process whicj is listening that port using cmd command on windows



                              netstat -a -b


                              then you can shut it down with tasks manager






                              share|improve this answer



















                              • 2





                                Sorry, I downvoted. You mention "on Windows". The "-b" parameter to netstat, which shows executable names, is specific to Microsoft Windows. (Unix netstat variations may have similar functionality, but is typically not using that same parameter.) However, the question said "Fedora", so the asker of this question was looking for information about Fedora 13 64bit, a different operating system. netstat's man page for Fedora indicates that using -p shows the PID (which can be used to identify the executable's name).

                                – TOOGAM
                                Jul 2 '16 at 11:14








                              • 1





                                There are several mistakes in this answer. The answer contains a grammatical error which could have been avoided. The answer also is not applicable to Fedora, which is clearly mentioned, in the first sentence of the question. It isn't like the question didn't contain this information when this answer was submitted 30 minutes ago, the question has not been edited since July 2011, which nearly 5 years ago. So I am taking this answer for what it is, a "me too" answer, which very rarely actually helpful.

                                – Ramhound
                                Jul 2 '16 at 11:36


















                              -3














                              I had the same issue, just look for the process whicj is listening that port using cmd command on windows



                              netstat -a -b


                              then you can shut it down with tasks manager






                              share|improve this answer



















                              • 2





                                Sorry, I downvoted. You mention "on Windows". The "-b" parameter to netstat, which shows executable names, is specific to Microsoft Windows. (Unix netstat variations may have similar functionality, but is typically not using that same parameter.) However, the question said "Fedora", so the asker of this question was looking for information about Fedora 13 64bit, a different operating system. netstat's man page for Fedora indicates that using -p shows the PID (which can be used to identify the executable's name).

                                – TOOGAM
                                Jul 2 '16 at 11:14








                              • 1





                                There are several mistakes in this answer. The answer contains a grammatical error which could have been avoided. The answer also is not applicable to Fedora, which is clearly mentioned, in the first sentence of the question. It isn't like the question didn't contain this information when this answer was submitted 30 minutes ago, the question has not been edited since July 2011, which nearly 5 years ago. So I am taking this answer for what it is, a "me too" answer, which very rarely actually helpful.

                                – Ramhound
                                Jul 2 '16 at 11:36
















                              -3












                              -3








                              -3







                              I had the same issue, just look for the process whicj is listening that port using cmd command on windows



                              netstat -a -b


                              then you can shut it down with tasks manager






                              share|improve this answer













                              I had the same issue, just look for the process whicj is listening that port using cmd command on windows



                              netstat -a -b


                              then you can shut it down with tasks manager







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Jul 2 '16 at 11:05









                              daqopdaqop

                              1




                              1








                              • 2





                                Sorry, I downvoted. You mention "on Windows". The "-b" parameter to netstat, which shows executable names, is specific to Microsoft Windows. (Unix netstat variations may have similar functionality, but is typically not using that same parameter.) However, the question said "Fedora", so the asker of this question was looking for information about Fedora 13 64bit, a different operating system. netstat's man page for Fedora indicates that using -p shows the PID (which can be used to identify the executable's name).

                                – TOOGAM
                                Jul 2 '16 at 11:14








                              • 1





                                There are several mistakes in this answer. The answer contains a grammatical error which could have been avoided. The answer also is not applicable to Fedora, which is clearly mentioned, in the first sentence of the question. It isn't like the question didn't contain this information when this answer was submitted 30 minutes ago, the question has not been edited since July 2011, which nearly 5 years ago. So I am taking this answer for what it is, a "me too" answer, which very rarely actually helpful.

                                – Ramhound
                                Jul 2 '16 at 11:36
















                              • 2





                                Sorry, I downvoted. You mention "on Windows". The "-b" parameter to netstat, which shows executable names, is specific to Microsoft Windows. (Unix netstat variations may have similar functionality, but is typically not using that same parameter.) However, the question said "Fedora", so the asker of this question was looking for information about Fedora 13 64bit, a different operating system. netstat's man page for Fedora indicates that using -p shows the PID (which can be used to identify the executable's name).

                                – TOOGAM
                                Jul 2 '16 at 11:14








                              • 1





                                There are several mistakes in this answer. The answer contains a grammatical error which could have been avoided. The answer also is not applicable to Fedora, which is clearly mentioned, in the first sentence of the question. It isn't like the question didn't contain this information when this answer was submitted 30 minutes ago, the question has not been edited since July 2011, which nearly 5 years ago. So I am taking this answer for what it is, a "me too" answer, which very rarely actually helpful.

                                – Ramhound
                                Jul 2 '16 at 11:36










                              2




                              2





                              Sorry, I downvoted. You mention "on Windows". The "-b" parameter to netstat, which shows executable names, is specific to Microsoft Windows. (Unix netstat variations may have similar functionality, but is typically not using that same parameter.) However, the question said "Fedora", so the asker of this question was looking for information about Fedora 13 64bit, a different operating system. netstat's man page for Fedora indicates that using -p shows the PID (which can be used to identify the executable's name).

                              – TOOGAM
                              Jul 2 '16 at 11:14







                              Sorry, I downvoted. You mention "on Windows". The "-b" parameter to netstat, which shows executable names, is specific to Microsoft Windows. (Unix netstat variations may have similar functionality, but is typically not using that same parameter.) However, the question said "Fedora", so the asker of this question was looking for information about Fedora 13 64bit, a different operating system. netstat's man page for Fedora indicates that using -p shows the PID (which can be used to identify the executable's name).

                              – TOOGAM
                              Jul 2 '16 at 11:14






                              1




                              1





                              There are several mistakes in this answer. The answer contains a grammatical error which could have been avoided. The answer also is not applicable to Fedora, which is clearly mentioned, in the first sentence of the question. It isn't like the question didn't contain this information when this answer was submitted 30 minutes ago, the question has not been edited since July 2011, which nearly 5 years ago. So I am taking this answer for what it is, a "me too" answer, which very rarely actually helpful.

                              – Ramhound
                              Jul 2 '16 at 11:36







                              There are several mistakes in this answer. The answer contains a grammatical error which could have been avoided. The answer also is not applicable to Fedora, which is clearly mentioned, in the first sentence of the question. It isn't like the question didn't contain this information when this answer was submitted 30 minutes ago, the question has not been edited since July 2011, which nearly 5 years ago. So I am taking this answer for what it is, a "me too" answer, which very rarely actually helpful.

                              – Ramhound
                              Jul 2 '16 at 11:36




















                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Super User!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f307624%2fhow-to-close-or-unbind-a-port-left-open-by-a-rogue-application%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

                              Mangá

                               ⁒  ․,‪⁊‑⁙ ⁖, ⁇‒※‌, †,⁖‗‌⁝    ‾‸⁘,‖⁔⁣,⁂‾
”‑,‥–,‬ ,⁀‹⁋‴⁑ ‒ ,‴⁋”‼ ⁨,‷⁔„ ‰′,‐‚ ‥‡‎“‷⁃⁨⁅⁣,⁔
⁇‘⁔⁡⁏⁌⁡‿‶‏⁨ ⁣⁕⁖⁨⁩⁥‽⁀  ‴‬⁜‟ ⁃‣‧⁕‮ …‍⁨‴ ⁩,⁚⁖‫ ,‵ ⁀,‮⁝‣‣ ⁑  ⁂– ․, ‾‽ ‏⁁“⁗‸ ‾… ‹‡⁌⁎‸‘ ‡⁏⁌‪ ‵⁛ ‎⁨ ―⁦⁤⁄⁕