Use port which is already in allocated to some process [duplicate] - java

When I run my Java project using Netbeans I get the following error:
Deployment error:
Starting of Tomcat failed, the server port 8080 is already in use.
See the server log for details.
at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:166)
at org.netbeans.modules.j2ee.ant.Deploy.execute(Deploy.java:104)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor619.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:277)
at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:460)
at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:151)
Caused by: org.netbeans.modules.j2ee.deployment.impl.ServerException: Starting of Tomcat failed, the server port 8080 is already in use.
at org.netbeans.modules.j2ee.deployment.impl.ServerInstance._start(ServerInstance.java:1297)
at org.netbeans.modules.j2ee.deployment.impl.ServerInstance.startTarget(ServerInstance.java:1251)
at org.netbeans.modules.j2ee.deployment.impl.ServerInstance.startTarget(ServerInstance.java:1062)
at org.netbeans.modules.j2ee.deployment.impl.ServerInstance.start(ServerInstance.java:939)
at org.netbeans.modules.j2ee.deployment.impl.TargetServer.startTargets(TargetServer.java:428)
at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:143)
... 16 more
BUILD FAILED (total time: 4 seconds)
I tried changing the server port to 8081 and shutdown port in tool->server. It runs fine but again if I do any operations and run the project it says "Deployment error:Starting of Tomcat failed, the server port 8081 is already in use"
What would be the problem?

goto command prompt
netstat -aon
for linux
netstat -tulpn | grep 'your_port_number'
it will show you something like
TCP 192.1.200.48:2053 24.43.246.60:443 ESTABLISHED 248
TCP 192.1.200.48:2055 24.43.246.60:443 ESTABLISHED 248
TCP 192.1.200.48:2126 213.146.189.201:12350 ESTABLISHED 1308
TCP 192.1.200.48:3918 192.1.200.2:8073 ESTABLISHED 1504
TCP 192.1.200.48:3975 192.1.200.11:49892 TIME_WAIT 0
TCP 192.1.200.48:3976 192.1.200.11:49892 TIME_WAIT 0
TCP 192.1.200.48:4039 209.85.153.100:80 ESTABLISHED 248
TCP 192.1.200.48:8080 209.85.153.100:80 ESTABLISHED 248
check which process has binded your port. here in above example its 248 now if you are sure that you need to kill that process fire
Linux:
kill -9 248
Windows:
taskkill /f /pid 248
it will kill that process

If you are behind a proxy server this issue could happen
i had the same issue and was solved by:
Preferences -> General -> Proxy Settings -> No Proxy.
"Maybe the tomcat ready-message was sent to the proxy - and never reached the IDE."
found #: https://netbeans.org/bugzilla/show_bug.cgi?id=231220

I had the same problem when trying to deploy, tomcat failed to restart as Tomcat instance was running. Close the IDE and check TASk Manager - kill any javaw process running, that solved the problem for me.

Take a look on your running processes, it seems like your current Tomcat instance did not stop. It's still running and NetBeans tries to start a second Tomcat-instance.
Thats the reason for your exception, you just have to stop the first instance, or deploy you code on the current running one

By changing proxy settings to "no proxy" in netbeans the tomcat prbolem got solved.Try this it's seriously working.

If on Linux you can kill existing Tomcats with this script
#/bin/bash
if [ `whoami` != root ]; then
echo "Please run this script as root or using sudo"
exit
fi
echo
echo "finding proceses that have name java and established connections status"
echo
echo "Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name"
netstat --tcp --programs | grep "ESTABLISHED" | grep "java"
echo
echo "finding proceses that use port 8080 or http-alt"
echo
netstat --tcp --programs | grep ':8080\|:http-alt'
echo -n "Do you wish to kill a process listed above?[Y/n]"
read choose
if [ "$choose" = "Y" ] || [ "$choose" = "y" ] || [ -z "$choose" ]
then
echo "enter pid to kill"
read procesId
kill -9 $procesId
fi
echo "done exiting"
exit 0

Kill the previous instance of tomcat or the process that's running on 8080.
Go to terminal and do this:
lsof -i :8080
The output will be something like:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 76746 YourName 57u IPv6 0xd2a83c9c1e75 0t0 TCP *:http-alt (LISTEN)
Kill this process using it's PID:
kill 76746

Select the project -> Right-Click -> clean and build and then run the project again simply solve the problem for me.
As, multiple process could bind the same port for example port 8086, In that case I have to kill all the processes involved with the port with PID. That might be cumbersome.

Change your default port in [tomcat_home_dir]/conf/server.xml
find
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
change it to
<Connector port="8090" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />

Change your Tomcat port address to 8084 and Shut Down Port to 8025. This will resolve your problem.
In other cases antivirus programs may cause problems. I had this problem with K7 total security. In my case K7 Firewall was blocking the 8084 port. The simple solution is to add an exception to Netbeans in K7 Firewall list.
In order to do that, open K7 and goto Settings -> Firewall Settings -> select Applications tab and find Netbeans.
Select Netbeans and click on edit link. On next screen select Grant Full Network access radio button.
Now goto Netbeans and start the server.

I resolved it by replacing Tomcat 8.5.* with Tomcat 7.0.* version.

This error message can also be caused by SELinux. Check if SELinux is enabled with getenforce
You need to adjust SELinux to use your port and restart.
I.E.
semanage port -a -t http_port_t -p tcp 9080 2>/dev/null || semanage port -m -t http_port_t -p tcp 9080

I tried No Proxy Settings , killing the process id . Some times they do work, But unfortunately they did not this time. So I tried the following.
In the Services Tab in NetBeans - Right Click on Apache Server {Version} - Platform Tab - Uncheck "Use IDE Proxy Settings". This solved the issue in my case.

I also had this problem. I changed port and did other things, but they didn't help me. In my case, I connected Tomcat to IDE after installing Netbeans (before). I just uninstalled Netbeans and Tomcat after that I reinstall Netbeans along with Tomcat (NOT separately). And the problem was solved.

Related

ApacheGUI Error ./run.sh: 1: [: -ne: unexpected operator

I have installed Apache GUI on Linux Debian in the following directory
/usr/local/apachegui/ApacheGUI/bin
by the following instruction as shown on this webpage:
https://www.howtoforge.com/tutorial/ubuntu-apache-gui/
At the end of the instruction, it's says run the following command:
sudo ./run.sh
when I run the above command I get the following output but with an error
./run.sh: 1: [: -ne: unexpected operator
Bottom of the terminal window its mention tomcat started and as in above mention tutorial webpage claims after running run.sh command
Your ApacheGUI is now starting and listening on port 9999.
Next, open your web browser and type the URL >http://your-server-ip:9999/ApacheGUI. You will >be redirected to the following page (ApachiGUI home page)
In my case when I am typing the above URL with my IP address or localhost my Chrome browser print: output site can not be reach
So I searched to check if port 9999 is enabled and listening in my case I was unable to see port 9999 in my list of ports so ran the following commands and the terminal window didn't produce any output from here I assumed port 9999 is close
pi#Home:~ $ ss -na | grep :9999
After using the above command terminal window return back to ip#home:$
now I open a separate terminal window and ping port 9999 and as result, This terminal window hang now it is clear the port 9999 is not open in my server so to open the close port I run the following command
Open port command:
sudo iptables -A INPUT -p tcp --dport 9999 -j ACCEPT
To update the firewall rules, I restart the iptables service
sudo iptables -L
output:
pi#Home:~ $ sudo iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp dpt:9999
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Now I check again a list of open ports on my server and I still can't see port 9999
After taking all these steps executed following command:
pi#Home:/usr/local/apachegui/ApacheGUI/bin $ ./run.sh
Output:
Using CATALINA_BASE: /usr/local/apachegui/ApacheGUI/tomcat Using
CATALINA_HOME: /usr/local/apachegui/ApacheGUI/tomcat Using
CATALINA_TMPDIR: /usr/local/apachegui/ApacheGUI/tomcat/temp Using
JRE_HOME: /usr Using CLASSPATH:
/usr/local/apachegui/ApacheGUI/tomcat/bin/bootstrap.jar:/usr/local/apachegui/ApacheGUI/tomcat/bin/tomcat-juli.jar
Tomcat started.
look like the initial error is resolved but I am still unable access ApacheGUI from my browser still unable to resolve the error mention above can anyone suggest what is the solution to this problem?
The run.sh file is a badly written shell script with content:
if [ $UID -ne 0 ]; then
sudo ../tomcat/bin/startup.sh
exit
fi
exec ../tomcat/bin/startup.sh
Just execute tomcat/bin/startup.sh. This script can fail in many ways:
there is no shebang (#!interpreter_name), so it is executed using /bin/sh or whatever the default shell is,
UID is not a POSIX variable (cf. this question), so the result is blank and test ([) only sees -ne 0. Usually in such cases the variable should be quoted or tested if it is not empty,
the path ../tomcat/bin/startup.sh is relative to the current directory, not the directory of the script.
By executing following tests you will learn port testing and port configuration and at the end of these test you will be able to find out either problem exist within your Server ports or you have to check the setting of your browser. In my case I have taken an unintentional long route, I set my testing plan into three sections as follow
Server Ports and Browser
If you ever experience the same issue my advise is to troubleshoot
Server Browser and then test Ports
By executing tomcat/bin/startup.sh it does start the server successfully just like run.sh (as mention in Question and given answer above) but the browser was still unable to load the localhost:9999/ApacheGUI index page because the server's initial error
./run.sh: 1: [: -ne: unexpected operator
was resolve (as shown in question) but the browser was still unable to load the GUI page so for this reason just to find out if there is a problem with port 9999 itself or there is something else causing localhost not to communicate with the browser via port 9999 I have carried out following tests:
I believe the following information is suitable for a tester who wants to troubleshoot ports but if you think there is nothing wrong with your ports and the problem may lies with the browser then visit the following link Where I had the same problem with port 8080 and I overcome this issue by modifying browser settings:
https://stackoverflow.com/questions/66524719/tomcat10-home-page-can-not-load-by-typing-localhost8080-error-err-connection-r
Reboot my server and execute the following command in terminal
tomcat/bin/startup.sh
output shows
Tomcat started
With this output, I know ApacheGUI is installed and the server is up and running.
Q: if the server is running so whey localhost:9999/ApacheGUI index
page is unable to load?
let's test port 9999 and take the following steps to check either it's port on your machine causing this error or it's something else
StepNO:1
pi#Home:~ $ nc -vz 192.168.0.16 9999
Connection to 192.168.0.16 9999 port [tcp/*] succeeded!
StepNO:2
type command on Linux terminal to test port 9999 (Enter)
pi#Home:~ $ sudo ls | nc -l -p 9999
(Cursor start flashing with no output)
StepNo:3
Then turn ON Window computer and open PuTTY client
Establish SSH connection from window machine by typing the following credentials in PuTTY Client interface:
Server: 192.168.0.16 port 9999
(Press Enter)
if port 9999 is open successfully you will get the following results
Linux Server Terminal (StepNO:2) Where cursor was flashing start responding to
Client request and print following line (where the cursor is still flashing):
SSH-2.0-PuTTY_Release_0.74
StepNO:4
Open a new terminal window and typed another command to make sure port 9999 is definitely open and responding (Linux Server terminal in StepNO:2 still open)
pi#Home:~ $ nmap -p 9999 192.168.0.16
Output:
Starting Nmap 7.70 ( https://nmap.org ) at 2021-03-05 23:44 GMT Nmap
scan report for 192.168.0.16 Host is up (0.00049s latency).
PORT STATE SERVICE 9999/tcp open abyss
Nmap done: 1 IP address (1 host up) scanned in 0.26 seconds
This stage confirmed I have successfully open port 9999 and the port is responding to
TCP protocols
StepNO:5
in the same Linux server terminal (stepNO:2) I type the following command again:
sudo ls | nc -l -p 9999 (Enter)
(Cursor start flashing)
Now I have open the browser and type ApacheGUI URL
192.168.0.16:9999/ApacheGUI (Enter)
Linux server terminal from StepNO:2 where the cursor is flashing start responding to
URL request from the browser and print the following lines in the terminal window:
Output:
GET /ApacheGUI/ HTTP/1.1 Host: 192.168.0.16:9999 Connection:
keep-alive Upgrade-Insecure-Requests: 1 User-Agent: Mozilla/5.0 (X11;
Linux armv7l) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/86.0.4240.197 Safari/537.36 Accept:
text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate Accept-Language: en-US,en;q=0.9
But: my ApacheGUI index page still unable to load and showing the following error message
This site can’t be reached192.168.0.16 refused to connect. Try:
Checking the connection Checking the proxy and the firewall
ERR_CONNECTION_REFUSED
At this stage, I am 100% sure that my installed server is up and running. Port 9999 in my server is open and functional so there is nothing else that can cause this error except the browser so I have followed the step to tune my browser setting as described in answer to the following link:
https://stackoverflow.com/questions/66524719/tomcat10-home-page-can-not-load-by-typing-localhost8080-error-err-connection-r
Result: Successful connection ApacheGUI index page finally loaded to the browser.

Web server failed to start. Port 8080 was already in use. Spring Boot microservice

I am trying to call webAPI from gradle project.
My build.gradle is as following.
plugins {
id 'org.springframework.boot' version '2.1.4.RELEASE'
id 'java'
}
apply plugin: 'io.spring.dependency-management'
dependencies {
implementation 'org.springframework.boot:spring-boot-starter'
runtimeOnly 'org.springframework.boot:spring-boot-devtools'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
compile 'org.springframework.boot:spring-boot-starter-webflux'
compile 'org.projectreactor:reactor-spring:1.0.1.RELEASE'
}
If I remove following dependency
compile 'org.springframework.boot:spring-boot-starter-webflux'
It works, but if I add it back. it gives error as
Web server failed to start. Port 8080 was already in use.
So, how do I fix this, so that I can use webclient? Because application is not web application which requires port to run. it is a sort of microservice.
I just want to use WebClient of Spring Boot. How do i use it without converting my application into web application.
If on windows and your getting this every time you run the application you need to keep doing:
> netstat -ano | findstr *<port used>*
TCP 0.0.0.0:*<port used>* 0.0.0.0:0 LISTENING *<pid>*
TCP [::]:*<port used>* [::]:0 LISTENING *<pid>*
> taskkill /F /PID *<pid>*
SUCCESS: The process with PID *<pid>* has been terminated.
If netstat above includes something like this;
TCP [zzzz:e2ce:44xx:1:axx6:dxxf:xxx:xxxx]:540yy [zzzz:e2ce:44xx:1:axx6:dxxf:xxx:xxxx]:*<port used>* TIME_WAIT 0
Then you can either wait for a little while or reconfigure to use another port.
I suppose we could write some code to randomly generate and check if a port is free when the application runs. Though this will have diminishing returns as they start to get used up. On the other hand could add a resource clean up code that does what we have above once the application stops.
You can change the default port of your application in application.properties by adding the following line:
server.port = 8090
If you don't want the embedded server to start, just set the following property in you application.properties (or .yml):
spring.main.web-application-type=none
If your classpath contains the necessary bits to start a web server, Spring Boot will automatically start it. To disable this behaviour configure the WebApplicationType in your application.properties
Source: https://docs.spring.io/spring-boot/docs/current/reference/html/howto-embedded-web-servers.html
If you application really is a Web application, then you can easily change the port using the server.port property (in your application's .properties/.yaml file, as a command line argument at startup, etc).
Another way to do this is by first checking what processes are using that specific port, then killing it using its process ID:
Run lsof -i :8080
This will identify which process is listening on port 8080.
Take note of the process ID (PID) e.g. 63262
Run kill -9 <PID> e.g. kill -9 63262
Some time if you can manually kill the that port problem can solve.
Using CurrPorts software you can view what are the running all ports in your machine and you can kill that port if you want.
You can download CurrPorts from here. (download link is in bottom of the page)
============== OR ==============
Without CurrPorts you can do this using like below method also.
CMD as run as administrator
Enter netstat -a -o -n and hit enter. Now you can see like below. Port can see Local Address column after : sign.
select the process id(not port) that your port running and type taskkill /F /PID <process_id_here> command and hit enter.
You can use npm to kill the port
**npx kill-port 8080** //8080 for example
Requirement: npm
read more: https://www.npmjs.com/package/kill-port
create /resources folder inside src/main
create application.properties file inside /resources
write server.port=9090 //(use any port number of your choice)
if port:8080 already in use error occurs:
goto command prompt
.type command> .netstat -ano
.Enter->this will show all running port check port 8080
.type command> taskkill /F /PID 8080
.process will terminate.
you can set server.port= #some-available-port number in application.properties file
or run command prompt in administrator mode and run netstat -a -o -n.
Find the process id which is using port 8080.
Run taskkill /F /PID #Processid command
It's easy we have two methods to solve.
First one is to change the port number in your application.properties i.e
server.port=9999 // something like this...
and second is, to first stop the available running server and then re-run your server again.
I am sure it work :)
If you had previously started the spring boot app and forgot to stop before hitting play again then Go to windows task manager and locate the java application(Something like "OpenJDK Platform binary" and click on End Task. (Java app not eclipse). Then try running again. It worked for me.
open command prompt as administrator
step1: netstat -ano | findstr :<enter your 4 digit port number>
netstat -ano | findstr :8080
TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING 6436
TCP [::]:8080 [::]:0 LISTENING 6436
step2: taskkill /PID <enter above pid number(sometimes it shown 3/4/5/6 digits)> /F
taskkill /PID 6436 /F
SUCCESS: The process with PID 6436 has been terminated.
To reset port 8080, you need to find PID (Process ID) and specify it for the command as, for example, on the screen 10512:
taskkill /F /PID 10512
You try to use an already used port.
Ports are used on the transport layer - tcp, http is application layer and uses a transport layer to send and receive requests.
Default port exposed by spring boot app is 8080. In your case you have two solutions:
change port for your application
stop the service that uses the port you want to use
to catch java.net.BindException e with message: Address already in use and to start on other available port and to use webclient with one of 2 ports.
try {
SpringApplication.run(Application.class, args);
} catch (org.springframework.boot.web.server.PortInUseException e) {
//Runtime.exec("pkil")..
//or
SpringApplication.run(Application.class, otherargs);
//SpringApplication.run(Application.class, new String[]{"--server.port=8444"});
//when invoked recursively it is a port rebalancer for port usage among port pool with server as from client for startup stage via application restarts within many busy ports which are used before or without querying.
}
The error basically means that your port 8080 is occupied. If you are getting this error then go to your project and open application.properties and add the below line and it should work fine:
server.port = 8090
Your client application also spring boot application, whats why you have two spring boot application run in 8080 port.
Change port one of them or create a standalone java application with main class, put your web client in it and run.
As http client you can use Apache Http Client.
Today I was working in Spring Boot project and I got the same error in my project. So, what I did, I clicked on stop button beside the run last tool button and run again. Then, my project started working very well.
You can also write services.msc in your search bar in windows.Then you can find Apache Tomcat and then just stop this apache. I think its gonna be work.
It is a simple answer.If you are getting this error then go to your project then
src/main/resources and open application.properties file and mention there
server.port=8045 you can give your own number here instead of 8045
thanks
Open cmd and type "netstat -ano -p tcp."
Then, look for the port number and PID.
Open up Resource Monitor and search for the PID number
Right Click and "End Process."
Restarting my machine solved the issue although I was getting below issue:
Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'webServerStartStop'; nested exception is org.springframework.boot.web.server.PortInUseException: Port 8081 is already in use
If you getting this error again and again , then make sure server.port=(your port no) is the first line in application.properties file.
The best answer to this is to always use the "Relaunch Application" button. That will stop the web server and restart the entire app on the same port as before.
It's the button with the red square and green play icon combined.
https://i.stack.imgur.com/ICGtX.png

Port 80 required by Tomcat v7.0 Server at localhost is already in use

I'm using Fedora I downloaded Tomcat 7 (apache-tomcat-7.0.34 , [url]http://www.coreservlets.com/Apache-Tomcat-Tutorial/tomcat7-files/tomcat-7.0.34-preconfigured.zip[/url]) and then add it to eclipse(Eclipse Java EE IDE for Web Developers. Version: Helios Release Build id: 20100617-1415). I want to start it from
but I get the following error:
Port 80 required by Tomcat v7.0 Server at localhost is already in use. The server may already be running in another process, or a system process may be using the port. To start this server you will need to stop the other process or change the port number(s).
I checked which process is working on port 80
[CODE]
netstat -an|grep 80
ps -aux|grep tomcat
[/CODE]
and there is no process is working on port 80. There is no tomcat running.
also I checked with lsof
# lsof -p :80
lsof: illegal process ID: :80
lsof 4.86
latest revision: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/
latest FAQ: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/FAQ
latest man page: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/lsof_man
usage: [-?abhKlnNoOPRtUvVX] [+|-c c] [+|-d s] [+D D] [+|-f[gG]] [+|-e s]
[-F [f]] [-g [s]] [-i [i]] [+|-L [l]] [+m [m]] [+|-M] [-o [o]] [-p s]
[+|-r [t]] [-s [p:s]] [-S [t]] [-T [t]] [-u s] [+|-w] [-x [fl]] [--] [names]
Use the ``-h'' option to get more help information.
# lsof -t -i:80
#
what are potential problem?
thanks
If you run eclipse on a Linux box, you most likely don't do that as root. In this case you can't open ports below 1024.
I have met the same situation.
I can give u another method to solve this problem.
double click Servers->server.xml,then u can see something like this.
what in server.xml
find out this line:
<Connector connectionTimeout="20000" port="80" protocol="HTTP/1.1" redirectPort="8543"/>
change port=''80'into another port,like port=88
Have a try~

Solr Configuration

I tried to installed Solr using:
java -jar start.jar
However I downloaded the source code and didn't compile it (Didn't pay attention). And the error was:
http://localhost:8983/solr/admin/
HTTP ERROR: 404
Problem accessing /solr/admin/. Reason:
NOT_FOUND
Then I downloaded the compiled version of solr but when trying to run the example configuration I'm getting exception:
java.net.BindException: Address already in use
Is there a way to revert solr configuration and start from scratch? Looks like the configuration got messed up. I don't see anything related to it in the manual.
Here is the error:
2011-07-10 22:41:27.631:WARN::failed SocketConnector#0.0.0.0:8983: java.net.BindException: Address already in use
2011-07-10 22:41:27.632:WARN::failed Server#c4e21db: java.net.BindException: Address already in use
2011-07-10 22:41:27.632:WARN::EXCEPTION
java.net.BindException: Address already in use
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:383)
at java.net.ServerSocket.bind(ServerSocket.java:328)
at java.net.ServerSocket.<init>(ServerSocket.java:194)
at java.net.ServerSocket.<init>(ServerSocket.java:150)
at org.mortbay.jetty.bio.SocketConnector.newServerSocket(SocketConnector.java:80)
at org.mortbay.jetty.bio.SocketConnector.open(SocketConnector.java:73)
at org.mortbay.jetty.AbstractConnector.doStart(AbstractConnector.java:283)
at org.mortbay.jetty.bio.SocketConnector.doStart(SocketConnector.java:147)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.Server.doStart(Server.java:235)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.xml.XmlConfiguration.main(XmlConfiguration.java:985)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.mortbay.start.Main.invokeMain(Main.java:194)
at org.mortbay.start.Main.start(Main.java:534)
at org.mortbay.start.Main.start(Main.java:441)
at org.mortbay.start.Main.main(Main.java:119)
Jul 10, 2011 10:41:27 PM org.apache.solr.core.SolrCore registerSearcher
INFO: [] Registered new searcher Searcher#5b6b9e62 main
This means you already have an application running on that particular port.
Run:
$ lsof -i :8983
This gives you a list of any application running on that port. In my case, Solr is already running, and I get back:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 10289 patricia 111u IPv6 399410 0t0 TCP *:8983 (LISTEN)
Kill this process by filling in your PID:
$ kill 10289
And then try running Solr again.
The java.net.BindException means that you are attempting to restart solr while an earlier instance continues to run, or less probably that you have something else running on port 8983. You should find that process, kill it, and then start solr again.
Its bound to a some other application. In case if its a important app you can change jetty default port using following:
java -Djetty.port=8181 -jar start.jar
ps aux | grep solr
OR
ps aux | grep start.jar
AND the get then process id and kill it:
kill -9 #PID#
example : kill -9 4989
UPDATE:
after killing the process if you want to reinstall solr you soul first uninstall it, the following is one of the solutions to uninstall it:
sudo service solr stop
sudo rm -r /var/solr
sudo rm -r /opt/solr-5.3.1
sudo rm -r /opt/solr
sudo rm /etc/init.d/solr
sudo deluser --remove-home solr
sudo deluser --group solr
An now you can reinstall it with no problem.
If sudo lsof -i:8983 won't help finding application running on the same port, the common mistake is Tomcat misconfiguration (if you're using it).
For example by default Tomcat listens on port 8005 for SHUTDOWN command and if you set another Connector to listen on the same port, you'll get port conflict.
So please double check in server.xml if these ports are different:
<Server port="8005" shutdown="SHUTDOWN">
<Connector port="8983" protocol="HTTP/1.1"
Maybe some crazy idea is to use docker to read a complete extended step by step and repeatable installation:
Here dockerhub to select the specific version tu run in docker Docker Hub Solr
And here github to read the docker recipe Solr docker Recipe

RAD - JVM debug port is in use

I am using RAD 7.5.0 and the websphere server v6.1. When i start the server in debug mode, it displays a error message states that
'Starting WebSphere application server in localhost; has encountered a problem.
JVM debug port #### is in use.
What is the problem? How to resolve this?
i also frustrated many times because of this eroor.. Finally found out the solution
To resolve this problem you will need to do the following to all of your subsequent servers:
1.Start the server in 'normal' mode (i.e. non-debug mode).
2.Launch the Administrative console and log in.
3.Expand 'Servers', click on 'Application Servers', and then your server instance (typically 'server1').
4.On the 'Configuration' tab expand 'Java and Process Management' and then click on 'Process Definition'.
5.Under the 'Additional Properties' header, click on 'Java Virtual Machine'.
6.Scroll to the bottom of the page, locate the 'Debug Arguments' text field, and increment the 'address' property at the very end of the string so it will use a unique port value.
7.Save your changes, exit the administrative console, stop the server, and then start it in debug mode
It simply means that the debug port is currently in use. Do you have any other IBM products already running on that box? Does this happen when you start your server for the first time or for subsequent tries?
One suggestion would be to hunt down rogue hanging Java processes and kill them (in case you don't need them) to resolve this.
Open task manager in admin mode and run the following two commands.
1: netstat -ano | findstr :PORT_NUMBER
e.g.: netstat -ano | findstr 7781
2: taskkill /PID PID /F (PID will be the number that is shown e.g.: 32181)
e.g.: taskkill /PID 32181 /F

Categories

Resources