Xcode HelloVapor run error

When building/running the HelloVapor project, I get this error:

Thread 1: Fatal error: Error raised at top level: bind(descriptor:ptr:bytes:) failed: Address already in use (errno: 48)

at line 3: in main.swift

I’m running on MacOS High Sierra 10.13.5 using Xcode 9.4.1 and Swift 4.1

This was in the console:

[ INFO ] Migrating ‘sqlite’ database (MigrateCommand.swift:20)
[ INFO ] Preparing migration ‘Todo’ (Migrations.swift:109)
[ INFO ] Migrations complete (MigrateCommand.swift:24)
Running default command: /Users/davidcutshaw/Library/Developer/Xcode/DerivedData/HelloVapor-akdxlbttcclituewsccprqbdlhdh/Build/Products/Debug/Run serve
Server starting on http://localhost:8080

1 Like

@rcutshaw this means that you have another program connected to port 8080. In Terminal run lsof -i :8080 to see what is connected and you can kill the process

11 Likes

Apples HomeKit Home app runs there. So maybe one should choose a port that does not interfere with system software?

MacBook-Pro:TILApp xxx$ lsof -i :8080
COMMAND PID     USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
homed   468 xxx 15u    IPv6 0xfae3ab8627d53107      0t0  TCP macbook-pro.local:49242->[fe80:d::217:88ff:fe25:813c]:http-alt (ESTABLISHED)

You could change the port to something different, like 9090. In your configure.swift, put the following code:

let serverConfigure = NIOServerConfig.default(hostname: "0.0.0.0", port: 9090)
services.register(serverConfigure)
3 Likes

@gjzwart Thank you for sharing the solution - much appreciated! :]

Running lsof -i :8080 and killing the process with kill {PID of the porcess} just like @0xtim sed works for me.

4 Likes

Dont make the same mistake I did and include the brackets :smiley:

Run the below command on the terminal:

sudo lsof -i :8080

kill -9 {PID}