'Error - Jenkins detected running multiple instances

I am running Jenkins as windows service. It was all good, suddenly from today noon I started seeing the following error while opening it.

Jenkins detected that you appear to be running more than one instance of Jenkins that share the same home directory '’. This greatly confuses Jenkins and you will likely experience strange behaviors, so please correct the situation.

This Jenkins: 17485453 contextPath="" at 1264@< MachineName >
Other Jenkins: 15621395 contextPath="" at 13424@< MachineName >

How this occurs? Any help to solve this?

Any help is appreciated !!



Solution 1:[1]

Stop your Jenkins service. Then use the Windows task manager or better the Sysinternals Process Explorer to kill all Jenkins processes. The numbers at the beginning of "1264@< MachineName >" and "13424@< MachineName >" indicate the id of the processes you need to kill. After that you should be able to start the Jenkins service again.

Solution 2:[2]

MacOS Solution for others directed to this question not on Windows:

Here is the error message I saw when I ran into this issue on MacOS: enter image description here

Here are the specs for that machine (if relevant): enter image description here

Despite the scary error message I was actually able to ignore this warning and use Jenkins for a month without noticing any catastrophes, but I'm sure mileage may vary.

I do not know what caused this condition initially.

Note: a search for "Jenkins" in the Activity Monitor reveals nothing, enter image description here

Using top is not that useful either. No Jenkins here… I do see a random Java process, which could be related, but we can’t be sure yet, enter image description here

Changing the search in the Activity Monitor to "Java" gives me what I want enter image description here

On the right side you can see my two Java processes, on the left side you can see that their PIDs match exactly the ones mentioned in the error message shown in the browser. A very nice indicator that we are not chasing some stray Java process. I especially don't want to kill a Java process that I don't know what it is doing.

I click the "Ignore this problem and keep using Jenkings anyway" button in the Browser to go to Jenkins GUI that I normally use.

I start using Jenkins, I actually start a build, so I can see which instance actually gets used. Logically, it’s CPU usage should go up in the Activity Monitor enter image description here

Cool. So I’m gonna keep the top one and trash the bottom one not being used. You can see that the top one is now using 0.2 or 20% of the available CPU.

Problem solved. As far as figuring out how both of them got spun up, that’s another issue. It’s probably related to how you installed and configured it, if you installed it twice, etc.

Solution 3:[3]

I had the same errors as the OP and I used Process Explorer as recommended above by Fabian to find two java.exe processes that were related to Jenkins. I killed both java processes using PE, restarted the Jenkins service and Jenkins now operates normally without error.

Solution 4:[4]

Alternatively use the Tomcat Manager Gui (http://:8080/manager/html) to stop/undeploy the duplicate process. Username and password is in tomcat/conf/tomcat-users.xml
if not add " password="" roles="manager-gui"/>

to the node.

Solution 5:[5]

Also, look at the details in the error message. I mean this part:

This Jenkins: 1234567890 contextPath="" at 12345@<MachineName>
Other Jenkins: 0978654321 contextPath="" at 54321@<MachineName>

Now the numbers between "at" and "@" are process IDs meant to help identifying the processes involved.

There are cases when those IDs and also the numbers before "contextPath" are the same. Read: "This Jenkins" and "Other Jenkins" is the same process.

This particular case is a known Jenkins bug, see here: https://issues.jenkins.io/browse/JENKINS-61792

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Fabian Ritzmann
Solution 2
Solution 3 Jeff Mergler
Solution 4 Daniel D
Solution 5 Attila Csipak