41

I deployed my vapor project to Ubuntu. And made the configuration of supervisor and Nginx.

When I invoke my server. first call is success but When I try second call I get 502 bad gateway error from browser. When I check error log, the error is

"Fatal error: Error raised at top level: bind(descriptor:ptr:bytes:) failed: Address already in use (errno: 98) : file /home/buildnode/jenkins/wo$"

If I kill the port(8080) process. And after, I try to connect again first try is success then get fail again.

What should I do to get rid of this error?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
sof98789
  • 1,051
  • 11
  • 17
  • perhaps: stop vapor. check which ports are in use: `sudo lsof -iTCP -sTCP:LISTEN -n -P` (Ubuntu 16.04). assign vapor instance to a unused port. also check that only one instance of vapor is launched per the assigned port. – marc-medley Nov 14 '18 at 23:35
  • I have the same problem with supervisor running. When I stop supervisor all works correct. – Vyacheslav Burlakov Nov 25 '18 at 20:39
  • @sof98789 were you able to resolve your issue? – LinusGeffarth Jan 22 '19 at 13:26
  • @LinusGeffarth unfortunately I cannot solve the problem. Because I had no idea, I discarded the project and use another template project that I found on github. And with that template everything works fine – sof98789 Jan 23 '19 at 07:17
  • Thanks for the reply! I was able to fix it as described [here](https://github.com/vapor/toolbox/issues/238). I'll post that as an answer... – LinusGeffarth Jan 23 '19 at 07:22
  • For Vapor 4 as mentioned in the docs of Vapor, I tried : `public func configure(_ app: Application) throws { app.http.server.configuration.port = 9090 try routes(app) }` – iCodes Apr 03 '21 at 13:20

2 Answers2

82

This might be caused by another process using that port.
I had the same issue and was able to solve it by listing all the processes on port :8080:

$ sudo lsof -i :8080

and then killing all of them one by one by typing:

$ kill {PID of the process}

After that, my app built again properly.


taken from here

LinusGeffarth
  • 27,197
  • 29
  • 120
  • 174
7

I had the same issue. This worked for me:

$ kill -9 {PID of the process}

Hope this helps!

anniina
  • 199
  • 1
  • 11