Arama Yap Mesaj Submit
Request a Callback
+90
X
X

Select Your Currency

Turkish Lira $ US Dollar Euro
X
X

Select Your Currency

Turkish Lira $ US Dollar Euro

Contact Us

Location Halkali merkez neighborhood fatih st ozgur apt no 46 , Kucukcekmece , Istanbul , 34303 , TR
Hermes Agent Windows VPS Setup: Codex, Caddy, HTTPS and Fallback
Hermes Agent, OpenAI Codex, Caddy and Windows Server

Hermes Agent on a Windows VPS: Complete Illustrated Setup Guide

This guide documents a real Hermes Agent deployment built from scratch on a Windows Server 2022 VPS, including the errors encountered and the steps required for production. It covers OpenAI Codex OAuth, the localhost API Server, Caddy HTTPS reverse proxy, 502 diagnosis, Windows services, startup without user login, a custom fallback provider and WISECP integration with 40 real screenshots.

Hermes AgentWindows VPSOpenAI CodexCaddyOpenAI Compatible APIFallbackWindows Server 2022
Hermes Gateway / Windows VPS
Hermes Agent → OpenAI-compatible API
127.0.0.1:8642 → Caddy → HTTPS
Primary model → fallback_providers
Windows Service + Scheduled Task → always-on
API127.0.0.1:8642TLSCaddy :443
4040 real screenshots
3TR · EN · DE content
443HTTPS reverse proxy
24/7Automatic startup
01Keep Hermes bound to localhost only
02Publish HTTPS through Caddy reverse proxy
03Start Caddy and Hermes automatically with Windows
04Fail over to fallback providers when the primary route fails
00
Table of contents

Steps in this guide

  1. 01Why run Hermes Agent on a dedicated Windows VPS?
  2. 02Start the Hermes Agent installation on Windows Server
  3. 03Complete the OpenAI Codex device authorization flow
  4. 04Choose the model and disable tools you do not need
  5. 05Enable the Hermes API Server on localhost only
  6. 06Start the gateway and verify the local health endpoint
  7. 07Test the OpenAI-compatible chat/completions endpoint
  8. 08Install Caddy on the Windows VPS
  9. 09Save Caddyfile without a .txt extension
  10. 10Separate 502 Bad Gateway from a backend connection refusal
  11. 11Receive the Hermes health response through the public hostname
  12. 12Run Caddy as a Windows service
  13. 13Run Hermes Gateway as a Scheduled Task
  14. 14Verify the endpoint with PowerShell and RDP closed
  15. 15Add a custom OpenAI-compatible fallback provider
  16. 16Fix Invalid JSON in request body by sending UTF-8 bytes
  17. 17Check gateway logs and background process status
  18. 18Connect Hermes to WISECP or a custom PHP application
01
Architecture and preparation

Why run Hermes Agent on a dedicated Windows VPS?

The goal is to place Hermes Agent between your web application and individual AI providers. Your application talks to one OpenAI-compatible endpoint while Hermes manages the primary model, fallback providers, and future capabilities such as web search, memory and scheduled jobs.

For production, keep the Hermes API bound to 127.0.0.1 and expose it through Caddy over HTTPS. DNS, TLS/reverse proxy and the Hermes process can then be diagnosed independently.

Step 1
WISECP / Web Application
        ↓
https://ai-api.example.com/v1
        ↓
Caddy :443
        ↓
127.0.0.1:8642
        ↓
Hermes Agent
        ↓
Primary model → Fallback chain
02
Hermes installation

Start the Hermes Agent installation on Windows Server

Hermes can be installed natively from PowerShell. Its data normally lives under the Administrator profile's LocalAppData hermes directory, including config.yaml, .env, auth.json, logs and sessions.

We used Full Setup because we wanted explicit control over the provider, model and tools. In the provider picker we then selected OpenAI.

Step 1
iex (irm https://hermes-agent.nousresearch.com/install.ps1)
Step 2
hermes --version
03
OpenAI Codex OAuth

Complete the OpenAI Codex device authorization flow

When OpenAI Codex is selected, Hermes starts a device authorization flow and prints a device URL plus a short-lived code. Open the URL, enter the code and approve access with the ChatGPT/Codex account you want Hermes to use.

After authorization, Hermes stores its own auth state. Treat device codes, auth.json and token values as secrets and never publish them in screenshots.

Step 1
https://auth.openai.com/codex/device
04
Model and tool permissions

Choose the model and disable tools you do not need

After OAuth, Hermes lists models available to the account. Model names can change over time, so choose an appropriate model from the list visible during your installation rather than treating a screenshot as a permanent requirement.

Because this VPS is primarily an AI API gateway for WISECP and custom web applications, we disabled high-privilege tools such as terminal execution, file operations, code execution, browser automation and computer use.

Add Web Search, Memory or Cron later only when the use case really needs them.

Step 1
hermes setup tools
Step 2
hermes setup terminal
05
API Server

Enable the Hermes API Server on localhost only

Once setup is complete, Hermes shows the locations of its config, .env and data directories. Enable the OpenAI-compatible API server by adding the API_SERVER variables to .env.

The critical setting is API_SERVER_HOST=127.0.0.1. Port 8642 is therefore not directly exposed on public interfaces; external traffic will enter through Caddy on HTTPS.

Use a long random API_SERVER_KEY and keep it only in server-side secret storage.

Step 1
notepad C:\Users\Administrator\AppData\Local\hermes\.env
Step 2
API_SERVER_ENABLED=true
API_SERVER_HOST=127.0.0.1
API_SERVER_PORT=8642
API_SERVER_KEY=STRONG_RANDOM_SECRET
API_SERVER_MODEL_NAME=hermes-agent
Step 3
$bytes = New-Object byte[] 32; $rng = [System.Security.Cryptography.RandomNumberGenerator]::Create(); $rng.GetBytes($bytes); ($bytes | ForEach-Object { $_.ToString("x2") }) -join ""
06
First runtime test

Start the gateway and verify the local health endpoint

The API Server starts with the gateway process. Before touching Caddy or Cloudflare, test /health in a second PowerShell window.

A healthy response proves Hermes is actually listening on port 8642 independently of DNS and TLS.

Step 1
hermes gateway
Step 2
curl.exe http://127.0.0.1:8642/health
07
Real model request

Test the OpenAI-compatible chat/completions endpoint

A health check proves liveness, not model inference. Send a real request to /v1/chat/completions with the API_SERVER_KEY bearer token.

In our test the request reached OpenAI Codex but the account returned HTTP 429 because its usage allowance had been reached. That is an upstream quota condition, not a broken local API.

Older Windows PowerShell/.NET builds may not support newer RandomNumberGenerator shortcuts. Use the byte-array method if key generation fails.

Step 1
$envFile = "C:\Users\Administrator\AppData\Local\hermes\.env"
$apiKey = ((Get-Content $envFile | Where-Object { $_ -like "API_SERVER_KEY=*" } | Select-Object -First 1) -replace "^API_SERVER_KEY=", "").Trim()
Step 2
POST http://127.0.0.1:8642/v1/chat/completions
Authorization: Bearer API_SERVER_KEY
08
HTTPS reverse proxy

Install Caddy on the Windows VPS

Our first Webi-based Caddy attempt failed in an elevated PowerShell session. This was a Webi installation issue, not a Hermes issue.

For a deterministic server setup, we downloaded the official Windows binary into C:\Caddy and opened inbound TCP 80 and 443 in Windows Firewall.

We did not create an inbound rule for 8642; the Hermes API remains loopback-only.

Step 1
New-Item -ItemType Directory -Force C:\Caddy
Step 2
curl.exe -L "https://github.com/caddyserver/caddy/releases/download/v2.11.4/caddy_2.11.4_windows_amd64.zip" -o "C:\Caddy\caddy.zip"
Step 3
Expand-Archive -Path "C:\Caddy\caddy.zip" -DestinationPath "C:\Caddy" -Force
Step 4
New-NetFirewallRule -DisplayName "Caddy HTTP 80" -Direction Inbound -Protocol TCP -LocalPort 80 -Action Allow
New-NetFirewallRule -DisplayName "Caddy HTTPS 443" -Direction Inbound -Protocol TCP -LocalPort 443 -Action Allow
09
Reverse proxy configuration

Save Caddyfile without a .txt extension

The Caddyfile only needs the hostname and reverse_proxy target. Windows Notepad may silently save it as Caddyfile.txt, which causes validation to fail because Caddyfile cannot be found.

Remove the extension, validate the configuration and then run Caddy.

Step 1
ai-api.example.com {
    reverse_proxy 127.0.0.1:8642
}
Step 2
Rename-Item "C:\Caddy\Caddyfile.txt" "Caddyfile"
Step 3
C:\Caddy\caddy.exe validate --config C:\Caddy\Caddyfile
Step 4
C:\Caddy\caddy.exe run --config C:\Caddy\Caddyfile
10
Troubleshooting

Separate 502 Bad Gateway from a backend connection refusal

If the domain reaches Caddy while Hermes is stopped, clients see 502 Bad Gateway. A Caddy log entry such as dial tcp 127.0.0.1:8642 connection refused means DNS/TLS is mostly working and the backend process is unavailable.

Run the local health check first. If it fails, restart Hermes. Do not troubleshoot Cloudflare and Hermes simultaneously when the local backend is already down.

Step 1
curl.exe http://127.0.0.1:8642/health
Step 2
hermes gateway
11
Public HTTPS

Receive the Hermes health response through the public hostname

When both Caddy and Hermes are running, the public /health URL returns the Hermes response. The request path is now Internet → Caddy → localhost:8642 → Hermes.

If you use Cloudflare, temporarily using DNS-only during origin certificate troubleshooting can simplify diagnosis. Re-enable the proxy after the origin path is confirmed.

Step 1
https://ai-api.example.com/health
12
Background operation

Run Caddy as a Windows service

A foreground caddy.exe run process stops when its PowerShell window closes. Register Caddy as an automatic Windows service instead.

STATE : 4 RUNNING from sc.exe query caddy confirms the service is active in the background.

Step 1
sc.exe create caddy start= auto binPath= "C:\Caddy\caddy.exe run --config C:\Caddy\Caddyfile"
Step 2
sc.exe failure caddy reset= 86400 actions= restart/5000/restart/5000/restart/5000
Step 3
sc.exe start caddy
Step 4
sc.exe query caddy
13
Hermes auto-start

Run Hermes Gateway as a Scheduled Task

Hermes can manage its Windows gateway through Scheduled Tasks. The documented flow registers the task with hermes gateway install, then uses gateway start/status to manage the detached background process.

For a production VPS, configure the task to run whether the user is logged on or not and enable highest privileges.

Change the trigger to At startup. If Windows asks for the task account password, enter the Administrator password locally and never place it in documentation.

Step 1
hermes gateway install
Step 2
hermes gateway start
hermes gateway status
Step 3
schtasks /Query /TN Hermes_Gateway /V /FO LIST
14
Reboot and logged-out test

Verify the endpoint with PowerShell and RDP closed

After service configuration we closed every PowerShell window and confirmed that the public health endpoint stayed online. The final test is a full reboot followed by checking the endpoint before logging in over RDP.

If it responds, Caddy and Hermes are starting independently of an interactive user session.

Step 1
Restart-Computer
Step 2
https://ai-api.example.com/health
15
Multi-provider resilience

Add a custom OpenAI-compatible fallback provider

Hermes can switch to another provider:model pair when the primary model encounters rate limits, server/auth failures or connection problems. Test a custom endpoint directly before adding it to Hermes so you know which layer is failing.

We tested openai/gpt-oss-20b on an OpenAI-compatible LLMGate endpoint, then stored the API key in .env and added endpoint/model metadata to the top-level fallback_providers list in config.yaml.

Use key_env to reference an environment variable instead of writing the secret directly into config.yaml.

Step 1
LLMGATE_API_KEY=PRIVATE_API_KEY
Step 2
fallback_providers:
  - provider: custom
    model: openai/gpt-oss-20b
    base_url: https://llmgate.waflare.net/v1
    key_env: LLMGATE_API_KEY
16
Windows PowerShell UTF-8

Fix Invalid JSON in request body by sending UTF-8 bytes

Windows PowerShell 5.1 may send a JSON string with an unexpected encoding. We hit Invalid JSON in request body when the payload contained Turkish characters.

Encoding the JSON as UTF-8 bytes and sending application/json; charset=utf-8 fixed the request. Because the primary Codex route was rate-limited, this successful response also verified the fallback path.

Step 1
$body = @{ model = "hermes-agent"; messages = @(@{ role = "user"; content = "Write a short VPS Hosting SEO description." }); max_tokens = 100 } | ConvertTo-Json -Depth 5
$utf8Body = [System.Text.Encoding]::UTF8.GetBytes($body)
Step 2
Invoke-RestMethod -Uri "http://127.0.0.1:8642/v1/chat/completions" -Method POST -Headers @{ Authorization = "Bearer $apiKey" } -ContentType "application/json; charset=utf-8" -Body $utf8Body
17
Logs and final verification

Check gateway logs and background process status

Gateway logs are the primary place to verify API Server startup, Scheduled Task behavior, model/fallback errors and restarts.

Check both Caddy and Hermes before connecting the final application. This keeps the application, reverse proxy, agent and upstream model layers independently observable.

Step 1
Get-Content "C:\Users\Administrator\AppData\Local\hermes\logs\gateway.log" -Tail 100
Step 2
Select-String -Path "C:\Users\Administrator\AppData\Local\hermes\logs\gateway.log" -Pattern "fallback|429|custom|gpt-oss" | Select-Object -Last 50
Step 3
sc.exe query caddy
hermes gateway status
18
Application integration

Connect Hermes to WISECP or a custom PHP application

The Hermes API Server is OpenAI-compatible, so an existing OpenAI-style client only needs a base URL, model alias and bearer key. The application does not need access to Codex OAuth credentials or fallback provider secrets.

Read API_SERVER_KEY from .env and store it only in server-side secrets. Never expose it in browser JavaScript. If only one application server uses the endpoint, add an IP allowlist/WAF rule as another layer.

Step 1
Provider: Hermes
Type: OpenAI-Compatible API
Base URL: https://ai-api.example.com/v1
Model: hermes-agent
API Key: the API_SERVER_KEY value from .env
Step 2
POST https://ai-api.example.com/v1/chat/completions
Production checklist

Security checklist before publishing or going live

Keep API_SERVER_HOST set to 127.0.0.1.
Do not create a public Windows Firewall rule for port 8642.
Use strong unique secrets for API_SERVER_KEY and fallback providers.
Never publish OAuth device codes, auth.json contents or tokens.
Keep terminal, file, code execution, browser and computer-use tools disabled unless required.
Where possible, add an application-server IP allowlist at Cloudflare/WAF.
Monitor Caddy and Hermes logs and distinguish 401/403/429/5xx conditions.
Redact IPs, secrets, tokens and device codes in screenshots before publication.
R
Official source

Official documentation and references

+
EKA Sunucu

Related EKA Sunucu links

?
FAQ

Frequently asked questions about Hermes Agent on Windows VPS

Does Hermes Agent run on Windows Server?

Hermes has native Windows support. This guide was implemented on a Windows Server 2022 VPS; the official Windows documentation explicitly lists Windows 10/11, so validate your server edition before production.

Do PowerShell windows need to stay open?

No. Once Caddy runs as a Windows service and Hermes Gateway runs through Scheduled Task, neither PowerShell nor an RDP session needs to remain open.

Should I expose port 8642 to the Internet?

Not in this architecture. Keep API_SERVER_HOST=127.0.0.1 and let Caddy expose HTTPS on port 443.

What does 502 Bad Gateway mean here?

It commonly means Caddy accepted the request but could not reach the Hermes backend. Test local /health first and check Caddy for connection refused.

Does the whole system stop if OpenAI Codex returns 429?

Not if you configure a supported fallback chain. Hermes can move to the next provider:model route for supported failure conditions.

Where should API_SERVER_KEY be stored?

In Hermes .env and server-side secret storage only. Never place it in browser JavaScript, screenshots, repositories or the public article.

Can I connect Hermes to WISECP or my own PHP site?

Yes. Hermes exposes an OpenAI-compatible /v1/chat/completions endpoint, so compatible clients can connect with a base URL, model alias and bearer key.

What kind of VPS should I use?

For an always-on gateway, choose a stable Windows VPS with enough CPU/RAM, administrator access and a static public IP. EKA Sunucu VPS packages are available on /vps.

EKA YAZILIM VE BİLİŞİM SİSTEMLERİ

Need a Windows VPS for Hermes Agent?

Explore EKA Sunucu VPS packages if you want to deploy the same Caddy, HTTPS, auto-start and AI gateway architecture on your own server.

Updated: 08.08.2026
View VPS PackagesAI & VPS Guides
Top