54

I try to launch a web application with IntelliJ IDEA, but I get an error: localhost:1099 already in use.

port 1099 is already in use

I checked the port 1099 with lsof -i:1099 and many other relative commands, so I'm pretty sure the port 1099 is free.

This is my running configuration:

configs

I've also changed the JMX port to 6666 & 6667 & 6668... and it doesn't work, so I think it's not really related to the port itself.

I am so confused... did anyone else have this problem?

Any help is appreciated

Adrian H.
  • 569
  • 6
  • 17
zmou-d
  • 834
  • 1
  • 8
  • 14
  • Which operating system are you running? You _may_ be encountering an issue with SELinux refusing the bind. – Matt Clark Aug 17 '16 at 21:26
  • "sudo fuser -k 1099/tcp" killing the process using that port works for me every time – whoopdedoo Sep 14 '17 at 12:03
  • Had this issue on Windows 10, on various IDEA versions – zlob Jul 26 '18 at 15:40
  • 1
    i meet the the problem in MacOSX. when i modify /etc/host, add the item: 127.0.0.1 localhost, then it works fine. – yuan wang Oct 17 '18 at 10:05
  • This is almost certainly NOT a problem with IDEA ... or any other IDE. It is an operating system level thing. Either it is an OS config problem, or some process is actually using that port already. – Stephen C Apr 22 '19 at 02:20

12 Answers12

64

Since it is easy to tackle with Command Prompt. You can do the following. I assume you work on Windows.

Open the CMD and type following.

netstat -aon | find "1099"

If a process uses above port, it should return something output like this.

TCP    xxx.xx.xx.xx:1099      xx.xx.xx.xxx:443      ESTABLISHED     2222

The last column value (2222) is referred to the Process ID (PID).

Just KILL it as follows.

taskkill /F /PID 2222

Now you can start your server.

Du-Lacoste
  • 11,530
  • 2
  • 71
  • 51
  • 10
    I get this all the time when running IntelliJ and Tomcat, but frustratingly netstat never shows the port in use. – Paul Vincent Craven Feb 24 '21 at 14:11
  • netstat -aon | find "1099" does not print any result. I change the port to 1098 or 10100 and same result :( – perezmlal Jul 12 '21 at 08:44
  • The Powershell equivalent of the command is `netstat -ano -p TCP | Select-string '1099'`. Its not your fault since you clearly state CMD but I'm sure people will land on the answer who are not paying attention to the subtle differences between Powershell and the CMD shell. – Anogoya Dagaate Oct 18 '21 at 20:36
32

Solution for those who can not find the process with `netstat -aon` command.

Some ports might be reserved by default in various networks. Therefore, if you can not find a :1099 port with netstat -aon command you need to check your reserved ports first.

netsh interface ipv4 show excludedportrange protocol=tcp

Port 1099 might show up as a reserved one in the list. However, it was not the case for me. I decided to try to make an exception for it anyway. It worked!

Follow these steps:

  1. Make sure to copy this text to your notepad, because you will lose internet connection for a moment.

  2. Open your CMD as an administrator.

  3. Write these commands one by one in order to stop your network:

    net stop winnat

    net stop LanmanWorkstation

    net stop WlanSvc

    net stop WwanSvc

  4. Exclude port 1099 from a reserved list:

netsh int ipv4 add excludedportrange protocol=tcp startport=1099 numberofports=4
  1. Start your network again:

    net start winnat

    net start LanmanWorkstation

    net start WlanSvc

    net start WwanSvc

  2. Done.

Temporary solution.

Simply changing JMX port to 1599 inside of the IntelliJ IDEA also solved this issue for me.

Alexander Borisov
  • 1,087
  • 12
  • 13
  • 1
    Finally!!!!! A working solution... spent last few hours trying all other suggested solutions without success. – Hussein Akar Jun 15 '21 at 07:08
  • 1
    Thanks man, this was the solution I was searching for months! – Tharindu Eranga Jul 07 '21 at 06:13
  • Thanks for the tip. It's sad to see, that it sometimes does not even work, when looking for these reserved ports. Mine wasn't showing up here, either. Just changing the port within IntelliJ "fixed" the issue... – Akito Apr 04 '22 at 10:38
  • this is the solution. apprently on my pc those ports changed overnight (might be my company...). solved – fedeb Apr 26 '22 at 08:33
  • This should be accepted answer as I have been facing this issue since long. I used to shutdown my system for 1 hour only then I could run some services. – inaitgaJ Jun 21 '22 at 19:14
7

cmd command netstat-ano: cmd command tasklist:

  1. The first step, the command prompt, execute the command:

    netstat –ano
    

    Visible, port 1099 process PID is 6072.

  2. The second step, the command prompt, execute the command:

    tasklist
    
  3. The third step, the task manager, the termination of the process java.exe

    We will see the opening of the 2 java.exe, to end it all.

  4. The fourth step, restart tomcat, can be started

derHugo
  • 83,094
  • 9
  • 75
  • 115
7

If you are a window user then Open cmd as an administrator and use netstat -aon | find "1099" and then you will get result like this

  TCP    0.0.0.0:1099           0.0.0.0:0              LISTENING       9960
  TCP    [::]:1099              [::]:0                 LISTENING       9960

In my case the LISTENING port is 9960 this may be different in your case. so use taskkill /F /PID 9960

for details look at this enter image description here

Monu Rohilla
  • 1,311
  • 5
  • 20
5

Actually it may caused by my hosts file,

I guess it's about the configurations about localhost :I deleted the configuration about localhost of ipv6 by accident,

so the solution is that I add a line ::1 localhost into hosts file and then everything work well!

zmou-d
  • 834
  • 1
  • 8
  • 14
  • Had the same problem here on OSX and the solution was to edit the /etc/hosts file also. But in my case, I already had the `::1 localhost` entry. I had several other entries, deleted everything not related to localhost and it worked – Sérgio Lopes Jun 14 '18 at 01:12
4

Had the same issue today. Try using

ps -C java -o pid

in the terminal. THis will give you a list of running programs. For me i had an existing java running in the background so i used

pkill java

Then just restart you intelliJ.

Celly
  • 325
  • 1
  • 14
  • 1
    I issued ps -fea | grep java and compared the pids with what was actually running and I shutdown only the server (weblogic) and that did the trick. – Icarin Feb 28 '17 at 15:57
4

in my case

  • netstat command did not show anything, on that port
  • tcpview did not show anything.

the solution was to:

net stop winnat

net start winnat

as David posted at: https://intellij-support.jetbrains.com/hc/en-us/community/posts/360006880600-IDEA-Start-Failed-Address-already-in-use

womd
  • 3,077
  • 26
  • 20
1

Try to kill all java tasks from O.S manager, maybe there is some ghost process running.

Dias Neto
  • 23
  • 4
1

1.Close Your Other running projects in same or other IDEs -or- 2.Close all java related running applications from Task Manager (java(TM) Platform SE binary)

The port:1099 is used by java.exe (http://www.nirsoft.net/utils/cports.html use the portable app in this link to view port usage (which program use that port))

I also faced it . i had opened both intellij and netbeans. when i run my project in Intellij , above problem raised. it solved after closed netbean and run my intellij project.

Yuresh Karunanayake
  • 519
  • 1
  • 4
  • 10
1

Thank you @ Dulith De Costa, Perfect Answer

netstat -aon | find "1099"

taskkill /F /PID "Process ID"

Now you can start your server.

Dilip
  • 31
  • 3
1

if you are using Mac,and the port is totally free ,you can check your hosts,and add 127.0.0.1 localhost if it's not exist

Xian Sheng.H
  • 299
  • 3
  • 6
0

Even if we don't have admin access, use the below command to kill the port

➜ lsof -i :9096

COMMAND   PID    USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME java    49455 test  171u  IPv6 0xccea5af095aca7d1      0t0  TCP
*:9096 (LISTEN)

kill 49455 (PID)

Wiki
  • 93
  • 6