Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Error: listen EADDRINUSE :::5858 is there a way to skip this port and start listinng on next avaialbe port ? #1661

Open
PManager1 opened this issue Dec 1, 2016 · 3 comments
Assignees
Milestone

Comments

@PManager1
Copy link

image

@mleanos mleanos self-assigned this Dec 2, 2016
@mleanos mleanos added this to the q milestone Dec 2, 2016
@mleanos
Copy link
Member

mleanos commented Dec 2, 2016

It's possible, but I don't see a huge advantage of doing this. This seems like it would only be useful in development environment. In my experience, most staging/production environments will expect a specific port to run the application in, or the environment itself (not the application) will assign a port when the app starts; this is the reason for process.env.PORT in the various env configurations.

If you wanted to achieve this, you could abstract the assignment of the port, in your express configuration, out into a recursive function that checks the availability of a port number, and returns the first available. You might want to have a max amount of tries for this, and/or base this off of a range of available port numbers. I believe express has a way for you to check if a port is in use already.

@keithics
Copy link

im running mutiple meansjs app in dev and I always got this error

@vaucouleur
Copy link
Contributor

@keithics Simply assign a different port number to each of your meanjs instance, the first paragraph in @mleanos answer above; many different way to do it; the simplest, arguably, is to mention the port number as an environment variable in your command line (when starting the instance).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants