Fly.io Deployment

When i flyctl deploy my app,
It builds correctly. On the monitoring page, everything seems fine:

Welcome back! To manage your project :rocket:, go to the administration
panel at: http://0.0.0.0:1337/admin To access the server :zap:, go to:
http://0.0.0.0:1337

But when I access my app in the browser, nothing shows up and I get a ERR_CONNECTION_RESET error.

I’ve read a post [Outage?] “Connection reset by peer” when using non-default ports which explains that fly.io will no more support non-default (80/443) ports for free, it will be charged 2$/month.

Could this be the cause of my problem ?

I’ve tested to manually change the Strapi port to 80; and it seems to work like this:

  • I’ve set PORT=80 in my .env file

  • Indeed, I also had to update fly.toml

    [[services]]
       ...
       internal_port = 80
    
    #also I added those
    [[services.ports]]
      port = 80
      handlers = ["http"]
      force_https = true
    
    [[services.ports]]
      port = 443
      handlers = ["tls", "http"]
    
  • and Dockerfile

     # Expose the Strapi port
     EXPOSE 80
    

Is this OK ? Is there a specific reason for Strapi to use port 1337 ?

Also, there’s an error in your NPM Dockerfile:

# Build the Strapi application
RUN yarn build

should be (I guess)

# Build the Strapi application
RUN npm run build

Maybe this guide needs an update ?