Try free

Last updated 13 October 2026

Fix a hanging Claude Code session

Your terminal stops responding to keyboard input

You are in the middle of a coding session when the interface stops moving. You type a command or a question, but the cursor does not move and no text appears. This is a common issue with command line tools that rely on a constant connection to a remote server. The Claude Code process might be stuck waiting for a response that will never arrive, or it could be caught in a local loop while trying to read a large directory.

A hang is different from a slow response. When the tool is slow, you might still see a loading indicator or a blinking cursor. When it hangs, the entire terminal window often becomes unresponsive to your keyboard. You cannot scroll back through your history or interrupt the current task. This usually happens because the underlying Node.js process has encountered an error that it cannot recover from without manual intervention.

Before you close the entire terminal window, you should verify if the problem is local or remote. Sometimes your internet connection drops for a few seconds. If the tool does not have a robust way to handle this drop, it stays in a waiting state indefinitely. You should check if other network-dependent tools are working. If your browser and other CLI tools are fine, the issue is specific to the Claude session.

Try standard signals before force closing

Your first instinct should be to use the standard interrupt signals. Press CTRL+C on your keyboard. In many cases, you need to press this combination two or even three times in rapid succession. This sends a SIGINT signal to the process, which tells it to stop what it is doing and return to the prompt. If the tool is just stuck in a long-running calculation or a large file read, this will often break the cycle.

If CTRL+C does not work, try CTRL+D. This signal represents the end of an input stream. Some terminal applications interpret this as a command to close the current session gracefully. You can also try typing /exit or /quit if the cursor is still responsive to any degree. These commands are the built-in ways to close the tool and allow it to save your conversation history before it shuts down.

Wait for at least thirty seconds after trying these signals. Sometimes the process is busy cleaning up temporary files or syncing your history to the local database. If the terminal remains frozen after this wait, the process is likely in a deadlocked state. At this point, you must move to more aggressive methods to regain control of your development environment.

Find the process identity on your system

To kill a stuck process, you first need to know its process ID, also known as a PID. Open a new terminal tab or window so you can run commands while the other one is frozen. If you are on macOS or Linux, use the ps command. Type ps aux followed by a pipe and the grep command to filter for the word claude. This will display a list of all active processes that match that name.

The output of the ps command shows several columns. Look for the column that contains a four or five digit number. This is the PID you need. There might be multiple entries if you are running several sessions or if the tool has spawned child processes. Usually, the process with the highest CPU usage or the one that has been running the longest is the parent process you want to target.

On Windows, the process is slightly different. You can use the Task Manager to find the process, but the command line is often faster. Open PowerShell and type Get-Process followed by a space and the name of the tool. This will show you the ID for every instance of the software currently running on your machine. Keep this number ready for the next step.

Terminate the hanging process forcefully

Once you have the PID, you can send a termination signal. On macOS or Linux, use the kill command. Type kill followed by the PID. This sends a SIGTERM signal, which asks the process to stop. If the process is completely frozen, it will ignore this request. If it does not stop within a few seconds, you must use a stronger signal. Type kill -9 followed by the PID. The -9 flag sends a SIGKILL signal, which forces the operating system to stop the process immediately.

Forcefully killing a process can have side effects. Since the tool did not have a chance to shut down properly, it might leave your terminal in a broken state. Your keyboard input might look like gibberish, or the enter key might stop working correctly. If this happens, type the command reset and press enter. This command re-initializes your terminal settings and should bring everything back to normal.

On Windows, use the taskkill command in your terminal. Type taskkill /F /PID followed by the process ID number. The /F flag stands for force. This works similarly to the SIGKILL signal on Unix-based systems. After you run this, the frozen terminal window should either close or return to a standard command prompt, allowing you to start over.

Clean up stale lock files in the config folder

Claude Code and similar CLI tools often use local databases to keep track of your settings and history. To prevent multiple instances from corrupting this data, they create lock files. When a process is killed forcefully, it cannot remove these lock files. If you try to restart the tool immediately, it might give you an error saying that another instance is already running.

You need to find the configuration directory on your system. On most machines, this is a hidden folder in your home directory named .claude or something similar. Navigate to this folder using your file manager or the cd command in your terminal. We do not know the exact names of every file the tool uses, but look for anything ending in .lock or files that have the word socket in their name.

Delete these lock files manually. Only do this if you are certain that no other Claude sessions are currently active. If you delete a lock file while a session is running, you might cause data corruption in your conversation history. Once the folder is clear of these temporary files, the tool should allow you to start a fresh session without any error messages.

Organize multiple sessions to prevent confusion

Managing many Claude sessions in separate tabs often leads to mistakes. You might kill the wrong process or forget which window was doing which task. This is why adhdTerminal is a useful tool for developers who run many Claude Code sessions side by side. It shows each session as a tile on a wall with a color, a number, and a name. You can see whether a session is working, waiting for you, or idle without clicking through tabs.

This clear overview helps you spot a hang immediately because the status indicator on the tile stops moving. If one tile hangs, you can identify it by its specific number or name and handle it without affecting your other work. The wall shows the last exchanges of each conversation, so you can see exactly where the hang occurred. This is much safer than searching through a long list of identical-looking processes in your terminal.

The app also includes a free iPhone app that mirrors the wall over an end to end encrypted link. If you have to step away from your computer while a long process is running, you can check the status on your phone. If a session hangs while you are away, you will see it on the mirrored wall. You can even use the phone app to answer a prompt or send the next task once the session is active again.

Restart your session and verify the file state

After you have cleared the stuck process and the lock files, you can restart your work. If you use adhdTerminal, this process is simpler because tiles reopen in the same place after a restart and resume the same session. This native app for macOS and Windows is made by MINDBALANCER OU in Estonia and is not affiliated with Anthropic. It costs 99 dollars once for a key that runs one computer at a time, which is helpful for keeping your environment consistent.

When you are back in the Claude session, the first thing you should do is check your project files. If the AI was in the middle of writing a file when it hung, that file might be corrupted or half-finished. Use a command like git status to see which files have been modified. Open those files and check for syntax errors or incomplete functions at the end of the file.

You can also ask Claude to summarize the last thing it did. Type a prompt asking for a status update on the current task. If the history was saved correctly, the AI should be able to tell you what it finished and what is still pending. If the history was lost due to the crash, you will need to provide the context again by pointing the tool to the relevant files in your project.

Check your network and server status

If you find that the tool hangs frequently, the problem might not be local. Claude Code depends on the Anthropic API to function. If their servers are experiencing high latency or outages, the CLI tool might struggle to maintain a connection. You can check the status of the API on official status pages, though we do not have a specific link for those here.

Your local network configuration can also cause issues. Some firewalls or proxy servers might drop long-lived connections. If your development environment is behind a strict corporate network, you might need to white-list the domains that the tool uses. Try switching to a different network, like a mobile hotspot, to see if the hangs continue. This will help you determine if the issue is with your computer or your connection.

Finally, ensure that you are using the latest version of the CLI tool and your runtime environment. Outdated versions of Node.js can have bugs in their networking stack that lead to hangs. Run the update command for your package manager to see if a newer version of the tool is available. Developers often release patches that specifically address stability and connection handling in these command line interfaces.

Questions people ask

Will I lose my conversation history if I kill the process?

Most versions of Claude Code save the history of your conversation after every completed turn. You will likely lose the most recent prompt you typed or the partial response the AI was generating when it hung. Once you restart the tool in the same directory, it should load the previous exchanges from its local database.

Why does my terminal show strange characters after I kill a session?

When a CLI tool hangs, it often fails to reset the terminal state, leaving it in raw mode. This causes your keystrokes to be interpreted incorrectly or not shown at all. Typing the command reset and pressing enter will clear the terminal buffer and restore the default settings for your shell.

How can I tell if Claude is hanging or just thinking?

Check your system monitor or task manager to see if the process is using CPU. If the CPU usage is zero percent for a long time and the network activity has stopped, the tool is likely hung. If there is high CPU usage, it may still be processing a large amount of local code or preparing a complex response.

Read next

More on when it goes wrong·All posts