Solved: Intellij Spring boot Gradle Error - Web server failed to start. Port 8080 was already in use

Solved: Intellij Spring boot Gradle Error - Web server failed to start. Port 8080 was already in use.

Have you ever encountered the below error in a Spring boot Gradle app on your WINDOWS machine with IntelliJ IDEA?

WEB SERVER FAILED TO START PORT **** WAS ALREADY IN USE

There could be a couple of solutions that you can try.

Solution 1: Find and Kill the process consuming the port

  1. Find a process consuming the port

    Use the below command in the WINDOWS command prompt using ADMINISTRATOR or WINDOWS PowerShell using ADMINISTRATOR
    netstat -a -n -p tcp -o | findstr 49415
    The result of the above command could be either
    NO RECORDS   or  
    TCP 192.168.1.32:49415 52.226.139.180:443 ESTABLISHED 7536
    Note down the Process ID - last digits 7536 in our case.
  2. Kill the process

    In order to kill the process using the below command
    kill --pid--
    that is
    kill 7536

Solution 2: Check the JDK version

If the Java SDK version is not your application supports then you can get such an error.

  1. Find the Java SDK version of the project in IntelliJ IDEA

    In order to find the Java SDK version set for the project in IntelliJ IDEA editor, on a Windows machine
    1. Click File
    2. Click on Project Structure
    3. On the left panel, under Project Settings, Click on the Project menu
    4. Find the option of SDK set for the current project.
  2. Edit the Java SDK for the project in IntelliJ IDEA
    Once you find the SDK option as per the above steps, Select OR edit the SDK version of lower OR higher, and click OK.
    Depending on the project you may need to set the SDK to the latest version or older version. Setting SDK to 1.8 should work in the most cases