Oracle Cloud Out of Host Capacity: Auto-Fix Script (2026)
When Oracle Cloud says "Out of host capacity" for the free ARM shape, your account is fine: the region has no free A1 hosts. I fixed it with a public GitHub Actions script that retries about once a minute, emails me when the instance exists and then disables itself. My 2 OCPU, 12 GB server took about 14 hours.
// contents
- 0:00 — Free 2 OCPU 12 GB server: the proof
- 0:19 — Why Oracle Cloud says out of host capacity
- 1:00 — How the auto-retry script works
- 1:56 — Fork the GitHub repo and keep it public
- 3:05 — Create an OCI API key
- 3:41 — Create a VCN with the wizard
- 4:51 — Generate SSH keys with ssh-keygen
- 6:31 — Create a Gmail app password
- 7:16 — Add the GitHub secrets
- 8:54 — Optional variables: shape, boot volume, run time
- 10:23 — Enable and run the workflow
- 10:55 — How the script retries and backs off
- 12:11 — Email alert and the workflow stops itself
- 12:53 — Stop Oracle reclaiming an idle instance
- 13:30 — Connect to the instance via SSH
- 14:25 — How long it takes to get capacity

New here? A new build-along tutorial lands on the channel every week.
Subscribe on YouTubeIf Oracle Cloud keeps saying "Out of host capacity" when you try to create the free ARM instance, your account is fine. The region has no free Ampere hosts left at that moment, and in Mumbai that was true for me almost every time. So I stopped clicking Create by hand and wrote a script that runs on GitHub Actions, keeps retrying, and emails me the moment the instance exists. It needs no server and no PC left switched on.
This is part 3 of the Oracle Cloud free tier series, and it fixes the error I hit in part 2. The script is public: oracle_sniper on GitHub.
Free 2 OCPU 12 GB server: the proof
The instance I promised is real: 2 CPU cores and 12 GB of RAM on Oracle's Always Free ARM shape. The proof is the email the script sent me, "Your Oracle Cloud instance is ready", with all the details inside.
It arrived around 12:30 at night. I recorded the video about three and a half hours later.
Why Oracle Cloud says out of host capacity
The error means Oracle has no free VM.Standard.A1.Flex capacity in your availability domain right now. Free ARM hosts are shared by everyone in the region, and popular regions like Mumbai, Hyderabad and Frankfurt fill up. When someone deletes an instance, a slot opens for a few minutes and the next request gets it.
In part 2 I fixed the "shape not available" error by editing the instance and picking another shape. That works when another free shape exists. When the only free ARM shape is full, editing doesn't help, and you get one of these:
Out of host capacity.
Out of capacity for shape VM.Standard.A1.Flex in availability domain AP-MUMBAI-1-AD-1Oracle's own troubleshooting page says to change the shape, fault domain or availability domain, or try again later. Mumbai has a single availability domain, so for most of us "try again later" is the real fix. A script does that far more patiently than I do.
How the auto-retry script works
The repo has one Python file (oracle_sniper.py) and one GitHub Actions workflow. GitHub starts the workflow every 15 minutes, and each run does this:
- Check whether an instance called
free-arm-serveralready exists. If it does, stop. - Find the availability domain, a public subnet that has an internet gateway, and the latest Ubuntu 24.04 ARM image.
- Ask for 2 OCPU / 12 GB. If that's out of capacity, wait 3 seconds and ask for 1 OCPU / 6 GB.
- Both full? Wait 60 seconds and try again. If Oracle answers
429 TooManyRequests, wait three times longer. - When a launch goes through, wait until the instance is
RUNNING, email the public IP, and disable the workflow so it never runs again.
The Always Free A1 limit in 2026: 2 OCPU, 12 GB
Read this before using any older guide or script. Oracle's Always Free resources page now gives every tenancy the first 1,500 OCPU hours and 9,000 GB hours per month on VM.Standard.A1.Flex. Run all month, that is 2 OCPUs and 12 GB of RAM. It used to be 4 OCPUs and 24 GB, and almost every tutorial and GitHub script I found still defaults to 4/24.
On a free-only account, a 4/24 request just fails with a limit error. On a Pay As You Go account it can actually succeed, and the extra half gets billed. That's why my script asks for 2 OCPU / 12 GB first and falls back to 1 OCPU / 6 GB.
Fork the GitHub repo and keep it public
Open the oracle_sniper repo and click Fork, then Create fork. Star it too, so you can find it again later.
Keep the fork public. GitHub Actions minutes are unlimited on public repos. On a private repo you get 2,000 free minutes a month, and once those run out the workflow stops, which would happen within days here.
GitHub disables workflows on a fresh fork. Open the Actions tab of your fork and click I understand my workflows, go ahead and enable them. On my own repo the Actions tab showed the runs that had gone all day before the success email.
Create an OCI API key
The script talks to Oracle through the API, so it needs an API key. Old guides say Profile → My profile. On newer consoles it is called User settings.
- Click the profile icon in the top right of the OCI console.
- Click User settings (older consoles: My profile).
- Open the Tokens and keys tab and find API keys.
- Click Add API key, keep Generate API key pair, download the private key (and the public one if offered), then click Add.
- Oracle shows a Configuration file preview. Click the copy button and paste it into a notepad. You need the
user,fingerprint,tenancyandregionlines in a minute.
If User settings isn't there either, go to ☰ → Identity & Security → Domains → Default → User management, open your user, and use its Tokens and keys tab.
Create a VCN with the wizard
The instance needs a network with a public subnet. Use the wizard, not the plain Create VCN form. The plain form makes you fill in everything yourself, and it only builds an empty VCN with no internet gateway, so an instance there would get an IP that you can't reach.
- Search for Virtual Cloud Networks in the console and open it, with the root compartment selected.
- If you opened Create VCN by mistake, cancel it.
- Click Actions → Start VCN Wizard.
- Choose Create VCN with Internet Connectivity and start the wizard. Everything else is filled in by default.
- Give it a name, click Next, then Create.
It takes about five seconds. You don't need to open the VCN afterwards. The script finds the public subnet by itself, and it skips any public subnet whose route table has no internet gateway, so leftovers from earlier attempts don't break anything.
Generate SSH keys with ssh-keygen
You log in to the server with this key. On Windows, open PowerShell (no admin needed) and run:
ssh-keygen -t rsa -b 4096 -f $HOME\.ssh\oci_sniper_sshPress Enter when it asks for a passphrase, or set one if you want to type it on every login. -t rsa -b 4096 is a 4096-bit RSA key, which Oracle accepts everywhere. -f writes it to its own file so your existing default key isn't overwritten.
You get two files. oci_sniper_ssh is the private key: it stays on your PC, you never share it, and you never commit it. oci_sniper_ssh.pub is the public key that goes on the server, the one line that starts with ssh-rsa. Copy it to the clipboard:
Get-Content $HOME\.ssh\oci_sniper_ssh.pub | Set-ClipboardOn macOS or Linux:
ssh-keygen -t rsa -b 4096 -f ~/.ssh/oci_sniper_ssh
cat ~/.ssh/oci_sniper_ssh.pubOn a Mac, pbcopy < ~/.ssh/oci_sniper_ssh.pub puts it on the clipboard.
If Windows says ssh-keygen is not recognized, the OpenSSH client is missing. Open Settings → System → Optional features → View features, search for OpenSSH Client, tick it, click Add, then open PowerShell again.
Create a Gmail app password
The success email goes out through Gmail SMTP, and Gmail won't accept your normal password from a script. You need an app password.
- Open Google account security and turn on 2-Step Verification if it's off.
- Open App passwords and verify yourself. I used a passkey, a normal password works too.
- Type a name (I used
ghostdevexplains) and click Create. - Copy the 16-character password into your notepad, then click Done. Google shows it only once.
A separate Gmail account just for these alerts is a good idea.
Add the GitHub secrets
In your fork, open Settings → Secrets and variables → Actions and click New repository secret once for each row. The names must match exactly.
| Secret | Value |
|---|---|
OCI_USER_OCID | the user line from the configuration preview |
OCI_TENANCY_OCID | the tenancy line |
OCI_FINGERPRINT | the fingerprint line |
OCI_PRIVATE_KEY | the whole downloaded .pem file, from -----BEGIN PRIVATE KEY----- to the END line |
SSH_PUBLIC_KEY | the oci_sniper_ssh.pub contents, one line starting with ssh-rsa |
SMTP_USER | the Gmail address that owns the app password |
SMTP_PASS | the 16-character app password |
EMAIL_TO | optional: where the alert goes, defaults to SMTP_USER |
I keep SMTP_USER and EMAIL_TO the same address. If a secret already exists, GitHub shows an error when you add it again, which is fine.
If your home region isn't Mumbai, open the Variables tab and add OCI_REGION with the value from the preview, for example ap-hyderabad-1. Always Free instances only exist in your home region.
Optional variables: shape, boot volume, run time
Everything here has a default, so you only add a variable when you want something different. Variables are visible in the logs, which is why no account value lives here.
| Variable | Default | What it does |
|---|---|---|
SHAPE_CONFIGS | 2:12,1:6 | OCPU:RAM_GB sizes, tried in order |
BOOT_VOLUME_GB | 100 | boot disk; keep it within the 200 GB free in total |
SHAPE | VM.Standard.A1.Flex | instance shape |
DISPLAY_NAME | free-arm-server | instance name |
RUN_MINUTES | 25 | how long one run keeps retrying |
RETRY_INTERVAL_SECONDS | 60 | gap between attempts, don't go lower |
Why 25 minutes when a run starts every 15? My first version ran for 15. On average a run took 21 to 22 minutes in total, because GitHub starts scheduled jobs according to its own load, and 4 or 5 minutes went missing between runs. With 25, the next scheduled run is already waiting before the current one ends. The workflow's concurrency setting makes it queue instead of running twice, so there is no gap and no overlap.
Enable and run the workflow
Open Actions → OCI A1 Sniper → Run workflow. It also runs by itself on the schedule, but a manual run lets you check the setup now.
Open the run and expand Try to launch instance. A working setup looks like this:
[08:09:50] Internet-connected public subnet found (1 available, using the first).
[08:09:51] Using image: Canonical-Ubuntu-24.04-aarch64-2026.11.05-0
[08:09:51] Region ap-mumbai-1 | VM.Standard.A1.Flex | trying: 2 OCPU/12 GB, 1 OCPU/6 GB
[08:09:53] #1 2 OCPU/12 GB: out of capacityThat "out of capacity" line is a pass. Login, region, network and image all worked, and Oracle simply had no room. You can click Cancel workflow here and let the schedule take over.
Optional: test the full flow on a free Micro instance
The first test can't prove the email works, because the ARM shape is full. The AMD Micro shape is also Always Free and usually has room.
- In Variables, add
SHAPE=VM.Standard.E2.1.MicroandDISPLAY_NAME=test-micro. - Click Run workflow. Within a few minutes you should get an email with the IP.
- Clean up: in OCI, Compute → Instances → test-micro → Terminate with the boot volume deletion box ticked. Delete the two variables, then click Enable workflow on the Actions page.
If the Micro shape is out of capacity too, skip this. The first test already proved the setup.
Fix common errors
| Log line | What it means |
|---|---|
Missing required setting: OCI_USER_OCID | that secret is missing or its name has a typo |
SSH_PUBLIC_KEY must be the contents of your .pub file | a private key is in SSH_PUBLIC_KEY |
HTTP 401 NotAuthenticated | wrong user, fingerprint or key, or the .pem was pasted partly. A brand-new API key can also take a minute or two |
HTTP 404 NotAuthorizedOrNotFound | wrong tenancy OCID or region |
No public subnet with an internet gateway found | run the VCN wizard again |
service limit exceeded | your tenancy has no free A1 quota left for that size, usually because another A1 instance already uses it |
out of capacity | normal, the script keeps going |
rate limited (429) | normal, the script backs off by itself |
Email failed: SMTPAuthenticationError | use the app password, not the Gmail password |
Older versions of the script let a private key reach Oracle, and the run died with HTTP 400 InvalidParameter: Invalid ssh public key type "-----BEGIN". The current script catches it first.
How the script retries and backs off
In a run's log you can see the loop: it first checks whether the instance already exists, then tries 2 cores and 12 GB, then 1 core and 6 GB, waits, and goes again. If an instance is already there, it disables the workflow straight away.
Each round takes a little over a minute: two launch requests 3 seconds apart, then the 60-second wait. Since the runs follow each other with no gap, that comes to around 50 rounds an hour and well over a thousand a day. When Oracle starts rate limiting, the script waits three minutes instead of one and then carries on.
One more case it handles: sometimes Oracle accepts a launch and then takes the capacity back before the instance reaches RUNNING. The script notices, logs it, and keeps retrying.
Email alert and the workflow stops itself
When an instance finally reaches RUNNING, the script emails you the public IP and the SSH command, and the last step of the workflow disables it. On my repo the workflow showed as disabled from the moment it got the instance, and no more runs started.
Keep the repo and logs safe when public
The logs of a public repo are public too. Anyone can open your Actions runs, so the script is built to leak nothing:
- Every account value is a secret, and GitHub prints secrets as
***. Repository variables are printed in plain text, which is why no OCID lives in a variable. - Every line the script prints goes through a filter that removes OCIDs, IP addresses, emails, fingerprints, URLs and keys. The public IP and instance OCID go to your email only.
- The workflow has no
pull_requesttrigger, so someone else's pull request can't get at your secrets, and scheduled workflows are off on forks until the owner enables them.
Two things are still on you. .gitignore blocks .pem files and SSH key files, but run git status before every commit anyway. And if a key ever leaks, delete it in User settings → Tokens and keys and create a new one. Removing it from git history doesn't help, because the key itself is still valid until you revoke it.
Stop Oracle reclaiming an idle instance
Oracle reclaims Always Free instances that sit idle. According to Oracle's Always Free page, an instance counts as idle when, over 7 days, its 95th percentile CPU use is under 20%, network use is under 20%, and for A1 shapes memory use is under 20%. So do something with the server as soon as the email arrives. I had mine running within an hour or two.
For that first step I made a small public server you can deploy right away: fastapi-users-api on GitHub. It is a FastAPI app with CRUD endpoints for dummy users and a health check, using SQLite, so nothing else needs installing. 25 dummy users are added on the first start.
After you connect over SSH (next section), run these commands from its README on the server:
sudo apt update && sudo apt install -y git python3-venv
cd ~ && git clone https://github.com/MuhammadAhmadRaza087/fastapi-users-api.git
cd fastapi-users-api
python3 -m venv .venv
.venv/bin/pip install -r requirements.txt
sudo cp deploy/users-api.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now users-api
curl localhost:8000/healthThe service starts on boot and restarts if it crashes. It assumes the ubuntu user and the repo in /home/ubuntu/fastapi-users-api, which matches the Ubuntu image the script picks.
To check it, systemctl status users-api shows the service, and journalctl -u users-api -f follows its logs. The README also shows how to open port 8000 to the internet. The API has no authentication, so keep it on dummy data only.
Be honest with yourself about what this does. A tiny API that nobody calls uses very little CPU, network or memory, so on its own it may not keep you above Oracle's 20% line for long. It gets the server set up and running on day one. When you are ready for real use, delete this repo and deploy your actual project.
Connect to the instance via SSH
The email contains your instance's public IP. Open PowerShell and run this, with the IP from the email in place of YOUR_PUBLIC_IP:
ssh -i $HOME\.ssh\oci_sniper_ssh ubuntu@YOUR_PUBLIC_IPOn macOS or Linux it's the same with ~/.ssh/oci_sniper_ssh. Accept the host fingerprint the first time. Ubuntu images use the ubuntu user; Oracle Linux images use opc.
On my server I had already cloned and started the FastAPI repo, and curl against its health endpoint on localhost answered straight away.
How long it takes to get capacity
Not everyone gets lucky. I started the script in the morning and got the email around 12:30 at night, about 14 hours later, in Mumbai. It depends entirely on Oracle's capacity in your region. If capacity is free, you get it quickly. If it isn't, it can take a long time, and I've read Reddit comments from people who waited 14 or 15 days.
Run it once and leave it. It costs nothing to keep trying. When the email arrives, act the same day so the instance doesn't sit idle.
Get capacity faster with Pay As You Go
The single biggest thing people report is upgrading the account to Pay As You Go, and Oracle's FAQ says those accounts have different capacity limits. You aren't charged while you stay inside the Always Free limits, but a card is on file, so first create a budget alert under Billing → Budgets.
There's also a claim going around that Pay As You Go accounts still get 4/24 for free. That comes from support emails, not from Oracle's documentation, so I keep the script at 2/12 either way.
Next in this series we put this server to real use and deploy an app on it. New to Oracle Cloud? Start with part 1: the free account setup, then part 2: creating the free tier instance by hand.
- "Out of host capacity" means the region has no free A1 hosts right now, not that your account is broken.
- The Always Free A1 allowance is now 2 OCPUs and 12 GB, so the script asks for 2/12 first and falls back to 1/6.
- GitHub Actions starts a run every 15 minutes, each run retries for 25 minutes, and the workflow disables itself after success.
- Keep the fork public: Actions minutes are free there, and secrets stay masked in the logs.
- SSH_PUBLIC_KEY must be the .pub file, never the private key.
- Oracle reclaims A1 instances that stay under 20% CPU, network and memory for 7 days, so give the server real work quickly.
How do I fix out of host capacity in Oracle Cloud?
Is Oracle Always Free still 4 OCPU and 24 GB?
Does Oracle reclaim idle Always Free instances?
Is it safe to run this script in a public GitHub repo?
Why does OCI say Invalid ssh public key type "-----BEGIN"?
How long does it take to get a free ARM instance?
New posts in your inbox
Subscribe to get every tutorial.