Ask Steves · Daily notes · VPS, 20% off · AI Profit Lab · SEO · Money Hub

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

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

  1. 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.
  2. Update the system with sudo apt update && sudo apt upgrade, then install nginx, Certbot and your runtime.
  3. Turn on the firewall so only SSH and web traffic get in: sudo ufw allow OpenSSH, sudo ufw allow 'Nginx Full', then sudo ufw enable.
  4. Create an ordinary user for the app, so it does not run as root.
  5. Copy your code onto the server (with git or rsync) and install its dependencies, just as you did on your laptop.
  6. Put your API key and any other secrets in a .env file 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.
  7. Make the app listen on 127.0.0.1 and a port such as 3000. Then only nginx on the same machine can reach it, not the whole internet.
  8. 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 startup
    pm2 startup prints one more command. Copy it and run it.
  9. At your domain provider, add an A record pointing example.com at the VPS's IP address.
  10. Add an nginx site that passes visitors to your app:
    server {
        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;
        }
    }
    The proxy_buffering off line lets replies that stream in word by word reach the visitor straight away. Test with sudo nginx -t, then reload with sudo systemctl reload nginx.
  11. Get the certificate with sudo certbot --nginx -d example.com. Certbot changes the nginx file for HTTPS and sets up automatic renewal.
  12. 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.

GET A VPS, 20% OFF →

Affiliate link.

Related AI builds: How do I keep a small AI app running after a server restart? · How do I back up a small AI app and its data on a VPS? · How do I choose between a hosted AI model and one I run myself? · All daily notes