Cannot connect to already running ide instance. exception: process 2 is still running on linux mint – Linux

by
Maya Patel
alpine-linux exception intellij-idea

Quick Fix: Navigate to your Home directory, then .config/JetBrains/idedir/ and delete the .lock file. This should resolve the issue of not being able to connect to an already running IDE instance.

The Problem:

You are unable to launch a new instance of IntelliJ IDEA due to an error message stating that another instance is already running. This issue is commonly observed when trying to start the IDE, and it indicates that there is a lock file preventing the initiation of a new IDE instance.

The Solutions:

Solution 1: Remove the Lock File

If you are unable to connect to an already running instance of IntelliJ IDEA due to the error “Cannot connect to already running IDE instance. exception: process 2 is still running”, follow these steps:

  1. Open a terminal window.

  2. Navigate to the directory where IntelliJ IDEA is installed, along with the version of the program and edition (e.g., Ultimate, Community, etc.). This can usually be found in the following location:

~/.var/app/com.jetbrains.IntelliJ-IDEA-Ultimate/config/JetBrains/IntelliJIdea[version]
  1. Look for a file called .lock in the directory.

  2. Delete the .lock file.

  3. Try restarting IntelliJ IDEA.

Note: The .lock file is used by IntelliJ IDEA to indicate that an instance of the program is already running. By deleting this file, you are allowing a new instance of IntelliJ IDEA to start.

Solution 2: Use kill command

If you’re using Linux and encountering the “Cannot connect to already running IDE instance. exception: process 2 is still running” error, you can use the kill command to terminate the problematic process and resolve the issue.

Here’s how you can do it:

  1. Open a terminal window by pressing Ctrl + Alt + T or searching for “Terminal” in the application menu.
  2. Run the following command to find the process ID (PID) of the running IntelliJ IDEA instance:
  3. ps -eaf | grep java
    

    This command will display a list of running processes. Look for a process with the name “java” and the main class containing “IntelliJ IDEA”. Note down the PID of this process.

  4. Once you have the PID, run the following command to terminate the process:
  5. sudo kill -9 process_id
    

    Replace “process_id” with the actual PID of the IntelliJ IDEA process you identified in the previous step.

  6. For example:
  7. sudo kill -9 2915
    

    This command will forcefully terminate the IntelliJ IDEA process with the specified PID.

  8. After terminating the process, try restarting IntelliJ IDEA. The error should be resolved, and the IDE should start without issues.

Please note that this solution is specific to Linux systems. If you’re using a different operating system, the steps may vary.

Q&A

Unable to open application due to error message ‘Cannot connect to already running IDE instance. exception: process 2 is still running’. How can I resolve this issue?

Utilize ‘kill -9 [pid]’ command or remove ‘.lock’ file located in ‘Home/.config/JetBrains/idedir/’ directory.

On Linux, how can I resolve the ‘Cannot connect to already running IDE instance’ error?

Type ‘sudo kill -9 process_id’ in the terminal. For example: ‘sudo kill -9 2915’.

Video Explanation:

The following video, titled "Error while opening Intellij IDEA due to an already running process ...", provides additional insights and in-depth exploration related to the topics discussed in this post.

Play video

Your browser can't play this video. Learn more.