28 October 2026 · Practical AI builds
What do I need to run a small AI app on a VPS?
By the end of this you will have a small AI tool running on your own server all day. It will be reachable at your own web address over HTTPS, and it will restart itself if it crashes. It suits anyone who has something working on a laptop (a chatbot, a summariser, a form that sends text to an AI model) and wants it online without moving to a large hosting platform.
I learn my automation tips in the AI Profit Boardroom. Have a look here. Affiliate link.
What you need
- A small VPS running Ubuntu LTS. If your app calls a hosted AI model through an API, a modest plan with 1 to 2 GB of memory is usually enough. VPS plans cost a monthly fee, and the amount depends on the provider and the plan.
- A domain name (paid yearly) and access to its DNS settings.
- An SSH key so you can log in safely without a password.
- The runtime your app uses, such as Node.js or Python, at the same version you use on your laptop.
- A process manager, such as PM2 or systemd, to keep the app running and start it again after a reboot.
- nginx as the front door, plus a free Let's Encrypt certificate from Certbot for HTTPS.
- An API key for the AI model, if you use a hosted one. The provider bills you for usage.
- Basic comfort with a terminal. You will type a handful of commands. You will not write new code.
If you want to run the AI model itself on the server rather than calling an API, you need far more memory and often a graphics card (GPU). Most small tools call an API instead, and that is what this guide assumes.
Step by step
- Create the VPS with Ubuntu LTS and set up key-based login. If you have not done that before, see how to copy your SSH key to a server.
- Update the system with
sudo apt update && sudo apt upgrade, then install nginx, Certbot and your runtime. - Turn on the firewall so only SSH and web traffic get in:
sudo ufw allow OpenSSH,sudo ufw allow 'Nginx Full', thensudo ufw enable. - Create an ordinary user for the app, so it does not run as root.
- Copy your code onto the server (with git or rsync) and install its dependencies, just as you did on your laptop.
- Put your API key and any other secrets in a
.envfile in the app folder, readable only by the app user. Never put it in your code, in git, or in anything sent to the browser. - Make the app listen on
127.0.0.1and a port such as 3000. Then only nginx on the same machine can reach it, not the whole internet. - Start the app with PM2 and tell PM2 to come back after a reboot:
pm2 start app.js --name appname # or for Python: pm2 start app.py --name appname --interpreter python3 pm2 save pm2 startuppm2 startupprints one more command. Copy it and run it. - At your domain provider, add an A record pointing
example.comat the VPS's IP address. - Add an nginx site that passes visitors to your app:
Theserver { listen 80; server_name example.com; location / { proxy_pass http://127.0.0.1:3000; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_buffering off; } }proxy_buffering offline lets replies that stream in word by word reach the visitor straight away. Test withsudo nginx -t, then reload withsudo systemctl reload nginx. - Get the certificate with
sudo certbot --nginx -d example.com. Certbot changes the nginx file for HTTPS and sets up automatic renewal. - Set up an outside check that warns you if the site stops answering. See how to set up an alert when your website goes down.
What good looks like
You open https://example.com on your phone, the padlock shows, and the tool answers just as it did on your laptop. pm2 status shows the app as online. pm2 logs appname shows requests coming in and no errors repeating. If you reboot the server, the app comes back by itself within a minute or so, and your uptime check stays green apart from that short gap.
Watch out for
The most common mistake is leaving the API key somewhere it can leak: in front-end code, in a public git repository, or in a log. Treat it like a bank card. Also, anyone on the internet can now use your tool, and every request costs you API usage. Add a simple login or a per-visitor limit, and use the spending limit or usage alerts your AI provider offers, if it has them. Think about privacy too. Whatever people type is sent to the model provider, so say so on the page and do not invite personal or sensitive details. AI replies can be wrong, so keep a human check on anything that matters.
Questions people ask
Do I need Docker to run an AI app on a VPS?
No. A process manager such as PM2 or systemd is enough for one small app. Docker helps when you run several apps with different needs, or want the same setup on many machines.
Can I use cheap shared web hosting instead of a VPS?
Usually not for this. Most shared hosting will not keep a Node.js or Python process running all day, and it does not let you set up nginx yourself. Some plans do support apps, so check with your host.
So the recipe is a small Ubuntu server, your app running under a process manager on a private port, nginx and a free certificate in front, the API key kept out of sight, and an outside check watching it. You can get the same kind of VPS with 20% off at https://asksteves.co.uk/vps. Affiliate link.
Want more automation tips? The AI Profit Boardroom on Skool is where I get mine. Have a look here. Affiliate link.
Everything on this blog runs on one Hostinger KVM 8. This link takes 20% off the same box.
Affiliate link.