# I am getting error "Could not connect to the controller" after installation of Leapwork and I am unable to start the controller service

## Introduction
The Leapwork Controller is the central component in the Leapwork Automation Platform. The studio depends on it to gain access to all the flows and related assets. The Controller also manages the Agents used for executing the automation flows. When a user starts the Studio for the first time, it automatically shows the available Controller(s) and prompts the user to select which Controller to connect to. Leapwork cannot be used before this selection.

Leapwork controller is installed as a Windows service and it runs in the background. After installing Leapwork, if the user sees an error indicating an inability to connect, they need to check whether the controller service is running.

## Resolution 1
The user can open up services on the computer where the Leapwork controller is installed to verify the service is running and start the service manually if necessary. To check the service, follow these steps:

1. Go to the _Start_ screen and start typing "services." Click or tap the _View local services_ search result.
2. Alternatively, use the Run window: Press the Win + R keys, type "services.msc," and hit Enter or press OK.
3. The Services app window will open.
4. Look for the service named Leapwork Controller.

5. Check the status of the service. If it is not running, simply start or restart the service.

If the service is running, the user should be able to connect to the controller from the Studio. If an installation error occurs, the following error message may display:

Leapwork controller and agents run on specific ports for communication. An error indicating that port 9000 is already in use means another application is occupying that port.

### Default Ports for Each Component:
- Leapwork Controller: 9000
- Leapwork Controller API: 9001
- Leapwork Agent: 6777

To identify which application is using a port, follow these steps:

1. Open the command prompt: start » run » cmd or start » All Programs » Accessories » Command Prompt.
2. Type **netstat -aon | findstr [port_number]** (replace [port_number] with the actual port number) and hit enter.
3. If the port is in use, details of the application will display, including its PID (process ID).
4. Type **tasklist | findstr [PID]** to find the application name using that port.

If another application is using a default port, change the port for the Leapwork service accordingly. Refer to the [article](https://support.leapwork.com/s/article/IamgettingerrorCouldnotconnecttothecontrollerafterinstallationofLeapworkandIamunabletostartthecontrollerservice6330767a6c530) for changing the installation port.

Another common issue during service start/restart is:

This error typically occurs when the service runs under a Local Service account. Assign a Local System account:
6. Select your service, right-click, and select **Properties**.
7. Go to Logon Properties, select **Local System Account**, then click **OK.**

## Resolution 2
To check port availability and connectivity, use this PowerShell command (run as administrator):

```powershell
Test-NetConnection -ComputerName 10.61.121.119 -Port 9000
```

**Note:** Replace the IP address (10.61.121.119) with your destination IP and specify the port number.

If it returns "True," the specified port is open and reachable. If it returns "False," the port may be closed; contact your IT team for assistance.

### To uninstall Leapwork completely:
1. Uninstall LEAPWORK from the control panel.
2. Delete the "LEAPWORK" folder from C:\Program Files\.
3. Delete the "LEAPWORK" key from the registry editor (Computer\HKEY_LOCAL_MACHINE\SOFTWARE\LEAPWORK).
4. Delete the "LEAPWORK" folder from C:\Users\[profile]\AppData\Local\.
5. Restart the machine.

Refer to the articles for changing the controller port:
- [How to change the port number of the Leapwork Controller after installation](https://support.leapwork.com/s/article/HowtochangetheportnumberoftheLeapworkControllerafterinstallation633070d8a630b)
- [How to change Agent Port](https://support.leapwork.com/s/article/HowtochangeAgentPort633073b713252)

For any clarification, please contact our [Priority Support](mailto:prioritysupport@leapwork.com).
