Deploy Oxy on AWS
This guide walks you through deploying Oxy on Amazon EC2 instances with direct access. We’ll cover everything from setting up a virtual machine to configuring Oxy with proper data persistence.This guide sets up Oxy for direct access on port 3000. For production
deployments, consider implementing additional security measures such as HTTPS
with SSL certificates, authentication, and network access controls.
This is part of our Hands-on Deployment Guides. For
additional deployment options, see our Docker Deployment
Guide or the general deployment
overview.
Prerequisites
Before you begin, make sure you have:- An AWS account
- A domain name (optional, but recommended for production deployments)
- Basic familiarity with Linux command line
Creating an EC2 Instance
Follow these steps to create an EC2 instance in Amazon Web Services:Access AWS Management Console
Go to the AWS Management Console and sign in with your account.
Launch an Instance
Click the Launch instance button and configure your instance:
- Name: Choose a name for your instance (e.g.,
oxy-server) - Application and OS Images:
- Select Ubuntu Server 22.04 LTS (64-bit ARM or x86)
- For best value, choose the ARM-based Amazon Machine Image (AMI)
- Instance type:
- For ARM-based, select
t4g.small(2 vCPU, 2 GB memory) ort4g.medium(2 vCPU, 4 GB memory) - For x86-based, select
t3.small(2 vCPU, 2 GB memory) ort3.medium(2 vCPU, 4 GB memory)
- For ARM-based, select
- Key pair: Create a new key pair or select an existing one
- If creating a new one, make sure to download and save the private key file
- Network settings:
- Allow SSH traffic from your IP
- Allow HTTP traffic on port 3000 (custom TCP rule: TCP, Port 3000, Source: 0.0.0.0/0)
- Storage:
- Default 8 GB gp3 root volume is sufficient to start
Pointing Your Domain to Your EC2 Instance (Optional)
If you have a domain name and want to use it with your Oxy deployment:Access DNS Settings
Go to your domain registrar’s website (such as Route 53, Namecheap, or GoDaddy) and navigate to the DNS settings for your domain.
Add DNS Records
Add the following DNS record to point your domain to your EC2 instance:
- A Record:
- Host/Name:
@or your subdomain (e.g.,oxy) - Value/Points to: Your EC2 instance’s public IP address
- TTL: 3600 (or as recommended by your registrar)
- Host/Name:
You can find your EC2 instance’s public IP address in the AWS Console under EC2 → Instances.
Wait for DNS Propagation
DNS changes can take from a few minutes to several hours to propagate. You can check the status using online tools like whatsmydns.net.
Setting Up the EC2 Instance
Connect to your EC2 instance and prepare it for Oxy deployment:Connect to Your Instance
You can connect using the AWS EC2 Instance Connect from the AWS Console by selecting your instance and clicking “Connect”, or use SSH with your key file:
Installing Oxy CLI
Let’s install Oxy directly on the EC2 instance:Install Oxy
Run the official Oxy installation script:This script will download and install the latest stable version of Oxy.
Setting Up Oxy Workspace
Let’s use the built-inoxy init command to initialize a new workspace with all the necessary files and configuration:
Initialize Oxy Project
- Create a
config.ymlfile with your database and model configurations - Set up sample project files
- Create necessary directories like
agentsandworkflows
- Database settings (You can start with DuckDB for simplicity)
- Model configuration (e.g., OpenAI with your API key)
Alternative: Set Up Git and Clone Existing Project
If you already have an existing Oxy project in a Git repository, you should set up Git and clone your repository instead of using
oxy init.Configure Environment Variables
Create a standard Add your environment variables:Save and exit.Note: You won’t need to manually set the OpenAI API key in the environment as it’s already configured during the
.env file in the workspace directory:If you don’t set
OXY_STATE_DIR, Oxy will use the default location ~/.local/share/oxy/.
We recommend setting it explicitly for production deployments to make backups and maintenance easier.oxy init process.Setting Up and Starting Oxy as a Service
Let’s configure Oxy to run automatically on system startup and restart if it fails:Create a Systemd Service File
We specify port 3000 explicitly to match the security group configuration. The service will be accessible directly on this port from the internet.
ubuntu user which is standard on EC2 Ubuntu instances. If you’re using a different username, adjust accordingly.Save and exit.Enable and Start the Service
sudo systemctl daemon-reload sudo systemctl enable oxy sudo systemctl
View Logs (if needed)
If you encounter any issues, check the logs:This command will show you the live logs from the Oxy service.
Test the Connection
You can test if Oxy is responding properly:You should get a positive response indicating that Oxy is running.
Security Group Configuration
To ensure your Oxy deployment is accessible, verify your EC2 instance’s security group allows inbound traffic on port 3000:Find Your Instance's Security Group
Locate the security group associated with your EC2 instance (you can find this
in the instance details).
Add Inbound Rule for Port 3000
Edit the security group and add the following inbound rule: - Type: Custom
TCP - Port range: 3000 - Source: 0.0.0.0/0 (for public access) or your
specific IP range for restricted access - Description: Oxy HTTP access
Optional Configuration and Management
Everything up to this point completes the core setup of your Oxy deployment. The following sections cover additional aspects of managing your deployment that you may want to explore as needed.Data Persistence
It’s important to understand how Oxy handles data persistence:- Oxy uses PostgreSQL for its data storage
- For production: Use Amazon RDS for PostgreSQL or a self-hosted PostgreSQL instance
- For development: Use
oxy startto automatically set up PostgreSQL in Docker - Configure the database connection via the
OXY_DATABASE_URLenvironment variable
For production deployments on AWS:
- Use Amazon RDS for PostgreSQL for managed database service
- Set up automated backups with RDS snapshots
- Enable Multi-AZ deployment for high availability
- Configure connection pooling for better performance
Managing Your Deployment
Machine Recommendations
Oxy runs well with just 4GB of memory for most use cases.
| Usage Level | ARM-based (Best Value) | x86-based |
|---|---|---|
| Small (1-3 users) | t4g.small (2 vCPU, 2 GB memory) or t4g.medium (2 vCPU, 4 GB memory) | t3.small (2 vCPU, 2 GB memory) or t3.medium (2 vCPU, 4 GB memory) |
| Medium (3-5 users) | t4g.large (2 vCPU, 8 GB memory) | t3.large (2 vCPU, 8 GB memory) |
| Large (5-15 users) | t4g.xlarge (4 vCPU, 16 GB memory) | t3.xlarge (4 vCPU, 16 GB memory) |
Scaling on AWS
As your usage grows, you may need to scale your deployment:Vertical Scaling
- Stop your EC2 instance from the AWS Management Console
- Change the instance type to a larger size (e.g., from t4g.small to t4g.medium)
- Start the instance again
-
Reconnect and start your Oxy service:
Storage Scaling
If you need more storage for your Oxy data:-
Create a new EBS volume in the AWS Management Console:
- Go to EC2 → Volumes → Create Volume
- Choose a size and volume type (gp3 is recommended for balanced cost/performance)
- Create in the same Availability Zone as your EC2 instance
-
Attach the volume to your EC2 instance:
- Select the volume you created
- Actions → Attach Volume
- Select your instance and choose a device name (e.g., /dev/sdf)
-
Connect to your VM and mount the disk:
-
To make the mount persistent across reboots, add it to fstab:
Troubleshooting
Cannot access Oxy through the domain or public IP
Cannot access Oxy through the domain or public IP
- Check your EC2 instance security group: Ensure it allows inbound traffic on port 3000 from 0.0.0.0/0 (or your specific IP range)
- Verify Oxy is running:
sudo systemctl status oxy - Test local connection:
curl http://localhost:3000 - For domain issues: Run
dig yourdomain.comto verify DNS is pointing to your EC2 instance’s public IP - Check if your EC2 instance’s public IP has changed (this can happen after stop/start)
Oxy service won't start
Oxy service won't start
- View detailed logs:
sudo journalctl -u oxy -f- Verify environment file exists:cat ~/oxy-workspace/.env- Check service file:sudo cat /etc/systemd/system/oxy.service- Ensure workspace exists:ls -la ~/oxy-workspace- Verify Oxy binary is installed:which oxy
Data not persisting between restarts
Data not persisting between restarts
- Verify data directory exists:
ls -la ~/oxy-data- Check environment variable is set:grep OXY_STATE_DIR ~/oxy-workspace/.env- If you didn’t setOXY_STATE_DIR, check the default location:ls -la ~/.local/share/oxy/- Ensure proper permissions:sudo chown -R ubuntu:ubuntu ~/oxy-data
Instance stopped responding
Instance stopped responding
- Check if you’ve hit CPU credit limits (t-series instances are burstable) -
Consider upgrading to a larger instance type if consistently hitting limits -
View system metrics in the AWS EC2 console to diagnose resource constraints -
Check available disk space:
df -h
Connection refused or timeout errors
Connection refused or timeout errors
- Verify the EC2 instance is running in the AWS Console
- Check if the security group allows traffic on port 3000
- Ensure Oxy service is running:
sudo systemctl status oxy - Test if the port is open:
sudo netstat -tlnp | grep :3000
Next Steps
Once your AWS EC2 deployment is running:- Configure agents and workflows in your workspace
- Set up regular backups for your data
- Consider implementing a CI/CD pipeline for deploying configuration updates
- Monitor your EC2 instance’s resource usage and scale as needed