Your organization has reached its machine limit but able to create new machine

when i am creating the NEW machine 50 and trying to update the machine 1 or 2 or 3 its giving this error


Error updating Streamlit code: 422 Client Error: Unprocessable Entity for url: https://api.machines.dev/v1/apps/streamlit-hello47/machines/e825494f746078

Response Status: 422

Response Body: {"error":"Your organization has reached its machine limit. Please contact billing@fly.io"}
 
Failed to update code

but when i am creating a more new 50 machine its creating so the error reach machine limit is not making sense
this is my code which create a new app if app dosent exist

def deploy_or_update_app(app_name, streamlit_code, dependencies=None, region='iad'):
    """Comprehensive app deployment or update"""
    try:
        # Check if app exists
        app_info = check_app_exists(app_name)
        
        if not app_info:
            # Create app if it doesn't exist
            create_app(app_name)
            
            # Allocate IPs
            print("Allocating IPs...")
            with concurrent.futures.ThreadPoolExecutor() as executor:
                ipv4_future = executor.submit(allocate_ip, app_name, "v4")
                ipv6_future = executor.submit(allocate_ip, app_name, "v6")
                
                # Wait for both to complete
                ipv4_response = ipv4_future.result()
                ipv6_response = ipv6_future.result()
            
            print("IPs allocated successfully")
        
        # Prepare installation command
        install_cmd = install_dependencies(dependencies or [])
        
        # Encode the Streamlit code
        encoded_code = base64.b64encode(streamlit_code.encode('utf-8')).decode('utf-8')
        
        # Prepare machine configuration
        machine_config = {
            "name": app_name,
            "region": region, 
            "config": {
                "image": "registry.fly.io/myimaage",
                "env": {
                    "PORT": "8505"
                },
                "files": [
                    {
                        "guest_path": "/app/streamlit_app.py",
                        "raw_value": encoded_code
                    }
                ],
                "services": [
                    {
                        "ports": [
                            {
                                "port": 443,
                                "handlers": ["tls", "http"]
                            },
                            {
                                "port": 80,
                                "handlers": ["http"]
                            }
                        ],
                        "protocol": "tcp",
                        "internal_port": 8505,
                        "autostop": "suspend",
                        "autostart": True
                    }
                ],
                "processes": [
                    {
                        "cmd": [
                            "sh",
                            "-c",
                            f"{install_cmd} && streamlit run streamlit_app.py --server.port=8505 --server.address=0.0.0.0"
                        ]
                    }
                ],
                "guest": {
                    "cpu_kind": "shared",
                    "cpus": 2,
                    "memory_mb": 512
                }
            }
        }
        
        # Deploy or update machine
        url = f"{FLY_API_HOSTNAME}/v1/apps/{app_name}/machines"
        
        # Check if machine exists
        existing_machines = requests.get(url, headers=headers).json()
        
        if existing_machines:
            # Update existing machine
            machine_id = existing_machines[0]['id']
            
            # Suspend the machine
            suspend_url = f"{FLY_API_HOSTNAME}/v1/apps/{app_name}/machines/{machine_id}/suspend"
            suspend_response = requests.post(suspend_url, headers=headers)
            suspend_response.raise_for_status()
            
            # Wait for suspension
            max_suspend_attempts = 90
            for _ in range(max_suspend_attempts):
                status = check_machine_status(app_name, machine_id)
                if status and status.get('state') == 'suspended':
                    break
                time.sleep(0.5)
            
            # Update machine
            update_url = f"{FLY_API_HOSTNAME}/v1/apps/{app_name}/machines/{machine_id}"
            response = requests.post(update_url, headers=headers, json={"config": machine_config["config"]})
        else:
            # Create new machine
            response = requests.post(url, headers=headers, json=machine_config)
        
        response.raise_for_status()
        machine_id = response.json()['id']
        
        # Monitor deployment
        start_time = time.time()
        timeout = 160  # 30 seconds timeout
        while time.time() - start_time < timeout:
            status = check_machine_status(app_name, machine_id)
            if status and status.get('state') == 'started':
                return {
                    "status": "success",
                    "message": "App deployed/updated successfully",
                    "app_url": f"https://{app_name}.fly.dev",
                    "machine_id": machine_id
                }
            time.sleep(0.5)
        
        return {
            "status": "error",
            "message": "Deployment timeout",
            "machine_id": machine_id
        }
    
    except Exception as e:
        print(f"Deployment error: {str(e)}")
        traceback.print_exc()
        return {
            "status": "error",
            "message": str(e)
        }

Hi… These are based on fuzzy heuristics, as I understand it, and hence there is no guarantee at the borderlines about when they do or do not fire.

Do email billing@fly.io, since a 50 machine fleet is big. (Everyone who has more than ~20 existing simultaneously has to go through this, from what I hear…)

isint it strange becasue when i am creating a new machine even 1k its working without any issues but the issues is happining only on update

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.