I have set up an Ubuntu instance on Google Cloud Platform and installed Swift-3 and Vapor on it. Then I tried to build the Vapor app with vapor build command and it succeeded. Then I run vapor run on the application folder, it successfully initiate the server and the console says that the service is available on local host, 0.0.0.0:8080.
But when I enter the static ip of my VM in the browser window I am not able to see the vapor page I am supposed to. Instead I am getting a connection refused error.
Port 80 is the default port for HTTP (non TLS) connections. It's likely that since Vapor is connecting to port 8080, it is being blocked by a firewall.
Try doing vapor run --port=80 --env=production (you may need sudo)
This will set the port to 80 and will also set the environment to production to prevent any debug logging that could slow your application down.
EDIT:
Port configuration is done through the Config/servers.json file now.
{
"default": {
"port": 8080,
"host": "localhost",
"securityLayer": "none"
}
}
However, you can still override through the command line interface with an updated command.
--config:servers.default.port=8080
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With