IntelliJ IDEA "Cannot Connect to Already Running IDE Instance" Error
Problem Statement
When attempting to launch IntelliJ IDEA on macOS, Linux, or Windows, you may encounter an error preventing the IDE from starting:
Cannot connect to already running IDE instance.
Exception: Process [ID] is stillThis occurs when IntelliJ detects a phantom process or lock file residue from a previous session, often due to:
- Unexpected IDE or system crashes
- Improper shutdown sequences
- Background processes failing to terminate
The error prevents IDEA from launching, requiring manual intervention to resolve.
Recommended Solutions
1. Terminate the Stuck Process (macOS/Linux)
Recommended when: You know the exact process ID (PID) from the error message
- Open Terminal
- Execute the kill command with your PID (replace
[PID]):
kill -9 [PID]# Example for PID 427:
kill -9 427WARNING
Verify the process belongs to IntelliJ using ps -p [PID] first. Killing unrelated processes could crash other applications.
2. Delete the Lock File
Recommended when: Process termination fails or PID is unavailable
- Locate IntelliJ's configuration directory for your OS:
~/Library/Application\ Support/JetBrains/[PRODUCT][VERSION]/~/.config/JetBrains/[PRODUCT][VERSION]/ # or ~/.var/app/... for Flatpak$env:APPDATA\JetBrains\[PRODUCT][VERSION]\- Remove the lock file:
rm -f .lockFinding Configuration Directory
Replace [PRODUCT][VERSION] with your specific IDE version:
- IntelliJ:
IdeaIC2023.2 - PyCharm:
PyCharm2023.2 - WebStorm:
WebStorm2023.2
Search for the .lock file using:
find ~ -type f -name '.lock' 2>/dev/null3. Alternative Solutions
Kill All IDEA Processes (macOS/Linux)
sudo killall -9 ideaRestart Computer
Use as a last resort when other methods fail. Clears all residual processes and locks.
Solution Hierarchy
- First attempt: Terminate the specific PID
- If PID missing/unknown: Delete
.lockfile - If lock file location unknown: Use
findcommand - Persistent issues: Try
killallor restart
Prevention
- Always exit IntelliJ properly using File > Exit
- Install stable versions and updates
- Avoid force-quitting the IDE unless necessary
Platform-Specific Paths
| OS | Typical Lock File Location |
|---|---|
| macOS | ~/Library/Application Support/JetBrains/IdeaIC2023.2/.lock |
| Linux | ~/.config/JetBrains/IntelliJIdea2023.2/.lock |
| Flatpak | ~/.var/app/com.jetbrains.IntelliJ-IDEA-Community/config/JetBrains/... |
| Windows | %APPDATA%\JetBrains\IntelliJIdea2023.2\.lock |
Resolving this error ensures interrupted work sessions can be quickly resumed without IDE reinstalls or configuration loss.