Connecting V2 apps outside Fly

# fly.toml file generated for

app = "<db-app-name>"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []

[[services]]
  internal_port = 5432 # Postgres instance
  protocol = "tcp"

  # Example of opening port 12500 for insecure connections.
  [[services.ports]]
    handlers = []
    port = 12500


[env]

[experimental]
  allowed_public_ports = []
  auto_rollback = true

[[services]]
  http_checks = []
  internal_port = 8080
  processes = ["app"]
  protocol = "tcp"
  script_checks = []
  [services.concurrency]
    hard_limit = 25
    soft_limit = 20
    type = "connections"

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

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

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

This is the fly.db.toml file and i added the following in it

[[services]]
  internal_port = 5432 # Postgres instance
  protocol = "tcp"

  # Example of opening port 12500 for insecure connections.
  [[services.ports]]
    handlers = []
    port = 12500

@amirhussain can you update to the latest version of flyctl and send us the output of ‘flyctl info’?

This is the result of the flyctl info -a <db-app-name>:

App
  Name     = <db-app-name>
  Owner    = <owner>
  Platform = machines
  Hostname = <db-app-name>.fly.dev

Services
PROTOCOL	PORTS	FORCE HTTPS

IP Addresses
TYPE	ADDRESS            	REGION	CREATED AT
v4  	<Ip-v4>       	    global	33s ago
v6  	<Ip-v6>	            global	1m18s ago

P.s. This is new DB created. If i will use the above config to deploy it again. It will crash.

I noticed you have two different services section within your fly.toml? Is that on purpose?

but in the fly dashboard it still shows: v0

Machine does not have the same versioning scheme as Nomad. So you should be able to ignore this.

It will crash.

Is there a specific error message you’re seeing?

I added this one to get the 12500 port for the postgres instance so i can connect it to Preset.io. Rest of the toml file was generated by this command:

fly config save --app <db-app-name>

All i want is to connect this V2 app to the preset.io.

Right, so for now, delete all other services you have defined within your fly.toml.

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

  [[services.ports]]
    handlers = []
    port = 12500

Then do the following:

# Run this to see what version of PG you're running.
fly image show
# Issue a new deploy
fly deploy .   --image flyio/postgres:<major-pg-version>

If this doesn’t work, please let me know you see on your end.

Once you get this working, i’d also look into this:

by running fly image show under version is N/A. What should i do ? Should i deploy it with 14.4?

If this is a new provision, using --image flyio/postgres:14.4 should be fine.

Okay the DB got deployed and it is is deployed stage for now. How should i connect it outside Fly?

What does fly info say?

App
  Name     = <db-app-name>
  Owner    = <owner>
  Platform = machines
  Hostname = <db-app-name>.fly.dev

Services
PROTOCOL	PORTS                 	FORCE HTTPS
TCP     	12500 => 5432 []      	False
TCP     	80 => 8080 [HTTP]     	True
        	443 => 8080 [TLS,HTTP]	False

IP Addresses
TYPE	ADDRESS            	REGION	CREATED AT
v4  	<IPv4>    	        global	11h38m ago
v6  	<IPv6>           	global	11h39m ago

@shaun it feels like adding this worked somehow :sweat_smile:

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

  [[services.ports]]
    handlers = []
    port = 12500

@shaun, I have implemented Multi region and i want to verify either it got implemented properly or is there an issue. How can i do that?

Looks like you never deleted the other services in that file, but happy the deploy worked.

You can find additional information on this process here:
https://fly.io/docs/postgres/the-basics/connecting/#connecting-external-services

You can test it by running:

psql postgres://<user>:<password>@<db-app-name>.fly.dev:12500

i deleted it from the toml file and deployed again and then deployed by the command you sent me and after that i ran fly info and it showed me that

How can i test my Multi Region implementation?

How can i test my Multi Region implementation?

This is pretty vague. What specifically are you trying to test?

like it is working like it is supposed to? :sweat_smile:
like the both clusters are working like they are meant to

@shaun i tried deploying again and using the pg_tls one you gave me above but it didn’t connect with the preset.io

@shaun connecting to apps link is not opening.