Using the fly.toml from github repo

Hi, im using heroku to deploy my projects and im trying to create a smtp server for testing purposes but i can’t allow the port 25 or 465 using fly.toml because fly.io doesnt use the fly.toml file from the github repository. Any idea how can i fix this?

Edit: trying to use the port 25 without process.env.PORT just gives me permission denied error so i can’t use it.

Edit 2: I managed to use it and activate the port with fly.toml but it still doesn’t work…
image
image

Can you paste your fly.toml?

allowed_public_ports is an experimental feature that exposes a port on each fo your instances’ unique IPv6 addresses.

For SMTP, you just need to add a normal port configuration for port 25.

# fly.toml file generated for turkey-mail on 2021-06-05T17:17:04+03:00

app = "turkey-mail"

kill_signal = "SIGINT"
kill_timeout = 5

[env]

[experimental]
  allowed_public_ports = [25]
  auto_rollback = true
  private_network = true

[[services]]
  http_checks = []
  internal_port = 8080
  protocol = "tcp"
  script_checks = []

  [services.concurrency]
    hard_limit = 25
    soft_limit = 20
    type = "connections"

  [[services.ports]]
    handlers = ["http"]
    port = 80

  [[services.ports]]
    handlers = ["tls", "http"]
    port = 443

  [[services.tcp_checks]]
    grace_period = "1s"
    interval = "15s"
    restart_limit = 6
    timeout = "2s"

  [[services]]
    internal_port = 25
    protocol = "tcp"

  [[services.ports]]
    port = "10025"

The port 10025 works but i want it to be the port 25 but i don’t know how will i do it (or mail services can’t send mails).

Are you deploying to Heroku or to Fly?

If your program is listening on port 10025 and you want to expose it on port 25, you need a fly.toml like:

app = "turkey-mail"

kill_signal = "SIGINT"
kill_timeout = 5

[[services]]
    internal_port = 10025
    protocol = "tcp"

[[services.ports]]
    port = "25"

[[services.tcp_checks]]
    grace_period = "1s"
    interval = "15s"
    restart_limit = 6
    timeout = "2s"

And then flyctl deploy.

I somehow managed to use it with fly so let me try!

Tried it and it didn’t work.
Heres the fly.toml file:

# fly.toml file generated for turkey-mail on 2021-06-05T17:17:04+03:00

app = "turkey-mail"

kill_signal = "SIGINT"
kill_timeout = 5

[env]

[experimental]
  allowed_public_ports = [25]
  auto_rollback = true
  private_network = true

[[services]]
  http_checks = []
  internal_port = 8080
  protocol = "tcp"
  script_checks = []

  [services.concurrency]
    hard_limit = 25
    soft_limit = 20
    type = "connections"

  [[services.ports]]
    handlers = ["http"]
    port = 80

  [[services.ports]]
    handlers = ["tls", "http"]
    port = 443

  [[services.tcp_checks]]
    grace_period = "1s"
    interval = "15s"
    restart_limit = 6
    timeout = "2s"

  [[services]]
    internal_port = 10025
    protocol = "tcp"

  [[services.ports]]
    port = "25"
    
  [[services.tcp_checks]]
    grace_period = "1s"
    interval = "15s"
    restart_limit = 6
    timeout = "2s"

(and yes im listening on the port 10025.)

Also in docs, it says that it only can listen to the ports 80, 443, 5000 and 10000 - 10100

Does the application deploy at all?

You can flyctl ssh console to get a shell and inspect your running application.

Are you listening on 0.0.0.0:10025 or [::]:10025? Only these 2 options will work to expose the port on Fly.

The docs are outdated a bit there. We added port 25 about a month ago.

The application deploys and im listening to 0.0.0.0:10025
image

I somehow can’t

I think the error message shows you to run flyctl ssh establish first. Try that and retry flyctl ssh console after.


This was the first try

This was the second try and i don’t know what will i do with this error (the error is in turkish).

I also noticed something about ports. Every port thats in docs gives me Error: Unexpected socket close but 25 doesn’t when it listens to that port…
It might be a issue with Fly

“Unexpected socket close” is expected when your app isn’t using a port.

You should update your fly CLI version and give SSH a try again. There have been some improvements recently that might help.

image
Tried updating and still the same issue.

and it doesn’t even happen to the port 25 when it doesn’t use it

Will you open an issue for the CLI + SSH console on GitHub - superfly/flyctl: Command line tools for fly.io services?

It seems like it’s not sending the right SSH keys to auth on Windows, but I’m not sure why.

Opened an issue for it.

So, i fixed the issue with the flyctl with this and what am i gonna do now?

Also, i still can’t use the port 25…
(first test was done with the port 10025 and the second one with the port 25.)
image