Error: listen EADDRINUSE: address already in use :::8080

Mikay² 0 Reputation points
2023-05-30T11:42:40.3133333+00:00

I try to get a webapp running on linux with nodejs 18 that works fine on Codespaces and on the server of a friend of mine.

However, when I try to host it on Azure, I always get the following error:

Listening on http://localhost:8080
Error: listen EADDRINUSE: address already in use :::8080

In my index.ts file I use the following code:

const port = Number(process.env.PORT);

In the Environment Variables in the Azure App Service I found that the following entry for the Port:

  • PORT = 8181

Can anybody help me?

I am no pro, so a simple explanation would be great.

Thank you!

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,965 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Grmacjon-MSFT 19,301 Reputation points Moderator
    2023-05-30T21:44:47.81+00:00

    Hi @Mikay² ,

    We are sorry to hear you're facing this issue. You're getting that error because it seems like the port 8080 is already in use. Here are a few things you could try to fix it:

    1. You can try changing the port number in your code to 8181, which is the port number specified in the environment variable in your Azure App Service.

    Example: const port = process.env.PORT || 8181

    1. You can find out which process is using the port 8080 and stop it. You can use the following command to find out which process is using the port:

    sudo lsof -i :8080

    This will give you the process ID (PID) of the process that is using the port. You can then use the following command to stop the process:

    sudo kill -9 <PID>

    Replace <PID> with the actual process ID that you got from the previous command. This will stop the process and free up the port. However, if you don't have control over the process that is using the port, or if you don't want to stop it, then changing the port number in your code is the best solution.

    Hope that helps.


    If the information helped address your question, please Accept the answer. This will help us and also improve searchability for others in the community who might be researching similar information.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.