Connecting V2 apps outside Fly

I need to connect my db outside fly that is preset.io. So last time i followed this guide for V1 app and it worked
Access fly.io database from Retool
but now it is not working for V2 apps and upon running

flyctl deploy -a <db-app-name> --config fly.db.toml

it gives me the following error:

? This feature is highly experimental and may produce unexpected results. Proceed? Yes
Deploying with rolling strategy ✓
Error failed to update VM <VM ID>: You are not allowed to create machines

Could be that your account is quarantined by some fraud detection system? Upgrade Required Message - #2 by zee

If your spend on Fly is more than £29, see: Restricted to shared-cpu-1x instances only - #2 by ignoramous

Hi @amirhussain seems like you got caught up in some of our internal fraud detection by accident, I’ve gone ahead and removed the restriction. Can you go ahead and try again?

sure, let me try to deploy again

Hey @DAlperin , I was able to deploy it but in the dashboard it still shows v0 instead of a new version.
Command i ran is:

flyctl deploy -a <db-app-name> --config fly.db.toml --strategy=canary

it gave me the following results:

? This feature is highly experimental and may produce unexpected results. Proceed? Yes
Deploying with canary strategy ✓

but in the fly dashboard it still shows:
image
and what is the procedure for connecting V2 apps outside Fly.

I was following this for V1 apps but it doesn’t seems to work for the V2 apps:

# 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