59API

← Volver a las guías

Using Claude Code with tmux on Remote Servers

Claude Code · EN · 2026-08-18

Why use Claude Code with tmux on a remote server?

If you use Claude Code for real development work, you will quickly run into a simple problem: your session should not die just because your laptop sleeps, your SSH connection drops, or you need to switch networks. That is where tmux and a remote server make a big difference. tmux lets you keep a terminal session alive on the server, so Claude Code can keep working even if you disconnect.

This setup is especially useful for long refactors, test-driven debugging, code review tasks, and multi-step changes across a large repository. Instead of restarting your workflow every time your connection changes, you attach back to the same session and continue exactly where you left off.

It also pairs well with cost-conscious API usage. If you want Claude Code access through an API relay that is cheap, pay-as-you-go, and compatible with Claude Code, 59API is a strong option. It supports native official-quality Claude models, uses the base URL https://api.59api.com, and offers a referral rebate, which can help reduce ongoing costs for frequent use.

What you need before you start

If you already use OpenAI SDK-compatible tools, the setup is easier because 59API is compatible with Claude Code, Codex, and any OpenAI SDK. That means you do not need a custom toolchain just to point your AI coding workflow at a different backend.

Step 1: Connect to the remote server

First, SSH into your server:

ssh your_user@your_server_ip

Make sure your system has a stable codebase and enough disk space for your project, logs, and dependencies. For best results, use a server with decent CPU and memory if you plan to run tests, linting, and large file edits inside the same session.

Step 2: Install tmux

On Ubuntu or Debian-based systems:

sudo apt update && sudo apt install tmux -y

On Fedora or similar distributions, use the native package manager. Once installed, create a session:

tmux new -s claude

This starts a named tmux session called claude. Naming sessions is helpful when you manage multiple projects or multiple AI workflows.

Step 3: Configure Claude Code for 59API

Set your API key and endpoint so Claude Code sends requests through 59API. The exact environment variable names may depend on your local Claude Code setup, but the core idea is the same: point the client to the relay at https://api.59api.com and use your 59API key for authentication.

A practical approach is to export the variables in your shell before launching Claude Code, or add them to your shell profile if you want them to persist:

This matters because 59API gives you access to native official-quality models without a downgrade, while staying among the cheapest relay options. For teams or solo developers who use AI coding tools daily, that price difference adds up quickly.

Step 4: Start Claude Code inside tmux

Now launch Claude Code from inside the tmux session. Because tmux keeps the terminal alive on the server, the session survives disconnects. You can close your laptop or lose Wi-Fi and reconnect later without losing the conversational context or terminal state.

Typical workflow:

When you return, reattach with tmux attach -t claude. This is the main advantage of the tmux approach: continuity.

Best practices for remote AI coding sessions

If you are working on a larger team, the referral rebate can also be a small but meaningful bonus. Developers who introduce teammates to the same relay can help offset usage while keeping the toolchain simple.

When this setup shines

Using Claude Code with tmux on a remote server is ideal when you need a persistent, hands-on coding assistant that stays available across sessions. It works well for remote debugging, production hotfixes, long code generation tasks, and overnight refactors. It is also a good fit if you want a lower-cost API path without giving up model quality.

If you want to try this setup, signing up for 59API is a straightforward way to get started with Claude Code-compatible access at a lower price point. Once your API key is ready, you can connect Claude Code to https://api.59api.com, launch it inside tmux, and keep your development workflow running even when your connection does not.

The result is a simple but powerful remote AI coding stack: SSH + tmux + Claude Code + 59API. For many developers, that is the easiest way to make Claude Code feel truly persistent, portable, and affordable.

Precios · Docs

¿Listo para empezar?

Conecta Claude y GPT en minutos a los precios más bajos, sin recortes. Regístrate para obtener tu clave API.

Registro gratis