Appendix: Hosting Options
This guide presents the different options for hosting your Spring Boot API, from local development to production.
1. Local Development (Free)
For development and testing, you need nothing more than your computer.
| Component | Local Solution |
|---|---|
| Application | ./mvnw spring-boot:run |
| Database | H2 (in memory) |
| Emails | MailHog (Docker) |
# Start MailHog to test emails
docker run -d -p 1025:1025 -p 8025:8025 mailhog/mailhog
# Start the application
./mvnw spring-boot:run
# Access the API: http://localhost:8080
# View emails: http://localhost:8025
Cost: $0
2. Why not Vercel?
Vercel is excellent for frontends (React, Next.js, Vue) but does not support Spring Boot:
| Criteria | Vercel | Spring Boot |
|---|---|---|
| Languages | Node.js, Python, Go | Java |
| Type | Serverless / Frontend | Traditional Backend |
| JVM | Not supported | Required |
Vercel = Frontend | Railway/Render/Heroku = Java Backend
If you have a React frontend + Spring Boot backend:
- Frontend → Vercel (free)
- Backend → Railway or Render (free)
3. Free Cloud Options (limited)
Railway
| Feature | Detail |
|---|---|
| URL | https://railway.app |
| Free | 500 hours/month + $5 credit |
| PostgreSQL | Included for free |
| Deployment | Automatic GitHub connection |
| Difficulty | Easy |
# Deploy on Railway
# 1. Connect your GitHub repo
# 2. Railway automatically detects Spring Boot
# 3. Add environment variables
# 4. Automatic deployment!
Render
| Feature | Detail |
|---|---|
| URL | https://render.com |
| Free | 750 hours/month (spin down after 15 min) |
| PostgreSQL | Free for 90 days |
| Deployment | GitHub or Docker |
| Difficulty | Easy |
Fly.io
| Feature | Detail |
|---|---|
| URL | https://fly.io |
| Free | 3 shared VMs |
| PostgreSQL | 3GB free |
| Deployment | CLI or Dockerfile |
| Difficulty | Medium |
4. Cheap VPS Hosting
Hostinger VPS
| Plan | RAM | CPU | Storage | Price |
|---|---|---|---|---|
| KVM 1 | 4 GB | 1 vCPU | 50 GB | $4.99/month |
| KVM 2 | 8 GB | 2 vCPU | 100 GB | $8.99/month |
| KVM 4 | 16 GB | 4 vCPU | 200 GB | $14.99/month |
Hostinger Advantages:
- Very competitive prices
- Simple management panel
- 24/7 support
- Free snapshots
Installation on Hostinger VPS:
# 1. Connect via SSH
ssh root@your-ip
# 2. Install Docker
curl -fsSL https://get.docker.com | sh
# 3. Install Docker Compose
apt install docker-compose -y
# 4. Clone your project
git clone https://github.com/your-user/your-project.git
cd your-project
# 5. Start with Docker
docker-compose up -d
DigitalOcean
| Plan | RAM | CPU | Storage | Price |
|---|---|---|---|---|
| Basic | 1 GB | 1 vCPU | 25 GB | $6/month |
| Basic | 2 GB | 1 vCPU | 50 GB | $12/month |
| Basic | 4 GB | 2 vCPU | 80 GB | $24/month |
Bonus: $200 free credit for students via GitHub Education.
Hetzner
| Plan | RAM | CPU | Storage | Price |
|---|---|---|---|---|
| CX11 | 2 GB | 1 vCPU | 20 GB | €3.29/month |
| CX21 | 4 GB | 2 vCPU | 40 GB | €5.83/month |
| CX31 | 8 GB | 2 vCPU | 80 GB | €10.59/month |
The cheapest in Europe!
OVH
| Plan | RAM | CPU | Storage | Price |
|---|---|---|---|---|
| Starter | 2 GB | 1 vCPU | 20 GB | €3.50/month |
| Essential | 4 GB | 2 vCPU | 40 GB | €6.50/month |
5. Platform as a Service (PaaS)
Heroku
| Plan | Detail | Price |
|---|---|---|
| Eco | 1000 shared hours/month | $5/month |
| Basic | Always on | $7/month |
| Standard | Performance | $25/month |
Heroku PostgreSQL:
- Mini: Free (10K rows)
- Basic: $9/month
- Standard: $50/month
Google Cloud Run
| Feature | Detail |
|---|---|
| Free | 2 million requests/month |
| Price | $0.00002/request after |
| Scaling | Automatic (0 to N) |
Ideal if you have low traffic!
6. Price Comparison
Cheapest Options
| Rank | Service | Price/month | Type |
|---|---|---|---|
| 1 | Hetzner CX11 | €3.29 | VPS |
| 2 | OVH Starter | €3.50 | VPS |
| 3 | Hostinger KVM 1 | $4.99 | VPS |
| 4 | Railway | $5 credit | Cloud |
| 5 | Heroku Eco | $5 | PaaS |
| 6 | DigitalOcean | $6 | VPS |
Free for Students
| Service | Student Offer |
|---|---|
| GitHub Education | DigitalOcean $200, Heroku, etc. |
| Azure for Students | $100 credit |
| Google Cloud | $300 credit |
| AWS Educate | Variable credit |
7. Recommendations by Use Case
For a Student Project
Recommended: Railway or Render (free)
Alternative: Heroku Eco ($5/month)
For a Personal Portfolio
Recommended: Hostinger VPS ($4.99/month)
Alternative: Hetzner (€3.29/month)
For a Startup / Production
Recommended: DigitalOcean or Hetzner
Alternative: Google Cloud Run (pay-per-use)
8. Production Configuration
Required Environment Variables
# Database
DB_HOST=localhost
DB_PORT=5432
DB_NAME=contactdb
DB_USER=postgres
DB_PASSWORD=secure_password
# Email (example with Gmail)
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USER=your@gmail.com
MAIL_PASSWORD=app_password
# JWT
JWT_SECRET=your_base64_256bits_secret_key
JWT_EXPIRATION=86400000
# Admin
ADMIN_EMAIL=admin@yourdomain.com
With Nginx (reverse proxy)
server {
listen 80;
server_name api.yourdomain.com;
location / {
proxy_pass http://localhost:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
With HTTPS (Let's Encrypt)
# Install Certbot
apt install certbot python3-certbot-nginx -y
# Obtain free SSL certificate
certbot --nginx -d api.yourdomain.com
9. Deployment Checklist
- Choose a host
- Create the server/instance
- Install Docker
- Configure environment variables
- Deploy with
docker-compose up -d - Configure a domain name (optional)
- Enable HTTPS (optional but recommended)
- Test the endpoints
10. Cheap Domains
| Registrar | .com Price | .dev Price |
|---|---|---|
| Namecheap | ~$9/year | ~$15/year |
| Porkbun | ~$9/year | ~$13/year |
| Cloudflare | ~$9/year (cost) | ~$11/year |
| OVH | ~€10/year | ~€15/year |
Tip: Cloudflare sells domains at cost price (no markup).
Summary
| Budget | Recommendation |
|---|---|
| $0 | Railway / Render / Local |
| ~$5/month | Heroku Eco or Hostinger |
| ~$10/month | DigitalOcean or Hetzner |
| Student | GitHub Education ($200 free) |