Machines API: Machine Stuck in "Created" State for New App, but Works for Existing App

Hi everyone,

I’m encountering a strange issue when trying to create a machine in a newly created Fly app using the v1 Machines API. The machine gets stuck in the created state and never starts.

When I send a POST request to /v1/apps/my-new-app/machines, the API call returns a successful 200 response and a machine object. However, looking at fly status or the dashboard, the machine remains in the created state indefinitely (I’ve waited over 30 minutes). It never transitions to started.

Once in this state, the machine is completely unresponsive. I can’t interact with it via fly machine stop/destroy or through the dashboard.

Here’s the weird part: this seems to be specific to the newly created app.

  • Works on Old App: If I run the exact same API call but target an older, existing app (my-old-app), it works perfectly. The machine starts up as expected.

  • fly deploy Works: Deploying to the new app (my-new-app) using fly deploy works correctly. This suggests the app itself is fine, but there’s an issue with my direct Machines API call.

  • Image is Not the Problem: The specific Docker image I’m using is not the issue. I can deploy it successfully to my-old-app via the Machines API.

  • Region Change Has No Effect: I have tried changing the region in the API call, but the result is the same.

Here is the curl request I’m using, with sensitive information like app names, image names, and the auth token redacted.

curl --request POST \
  --url https://api.machines.dev/v1/apps/my-new-app/machines \
  --header 'Authorization: Bearer [REDACTED_FLY_TOKEN]' \
  --header 'Content-Type: application/json' \
  --data '{
  "config": {
    "auto_destroy": true,
    "containers": [
      {
        "name": "pipecat",
        "image": "registry.fly.io/my-new-app:deployment-xxxxxxxx",
        "env": {
          "PORT": "7860",
        },
        "secrets": [
          { "env_var": "REDACTED" }
        ]
      }
    ],
    "restart": {
      "policy": "no"
    },
    "guest": {
      "cpu_kind": "performance",
      "cpus": 1,
      "memory_mb": 2048
    },
    "services": [
      {
        "internal_port": 7860,
        "protocol": "tcp",
        "ports": [
          {
            "port": 80,
            "handlers": ["http"],
            "force_https": true
          },
          {
            "port": 443,
            "handlers": ["tls", "http"]
          }
        ]
      }
    ],
    "checks": {
      "httpget": {
        "type": "http",
        "port": 7860,
        "method": "GET",
        "path": "/",
        "interval": "15s",
        "timeout": "10s"
      }
    }
  },
  "region": "iad, usa"
}
'

Has anyone encountered this behavior before? Is there a step I might be missing when setting up a new app that is required for direct Machines API interaction? It seems like fly deploy might be performing an extra initialization step that I am not.

Any help or insight would be greatly appreciated!

Thanks.

hmm, if a machine is stuck “created”, it’s possible there’s an error in our VM runner that isn’t properly exposed. you shouldn’t be needing to do anything other than create the machine.
can you let me know the app name or machine id so I can take a look?

Hello, thank you for your response

The app is called vox-calls-prod, and you can check out these two machine IDs:

  1. 90805091b59338 (iad)
  2. 2867591f961078 (lax)

I see this error message: secret SERVER_URL not found

Thank you so much! That was exactly it.

I can confirm that after setting the SERVER_URL (and one more) secret on the app, my API calls are now working perfectly and the machines are starting up as expected.

This also explains why it worked on my older dev app. It already had all the secrets set. I had incorrectly assumed that the API call would fail with a 4xx error if a referenced secret was missing, not that it would succeed and leave the machine in a created state.

This is a huge help and a great piece of information to have for future debugging. As a bit of feedback, it would be amazing if the API could surface that “secret not found” error back in the response to the create call.

Thanks again for your super quick help in diagnosing this! The issue is resolved.

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