My GitHub Actions Self-Hosted Runner Kept Exiting After One Job on AWS EC2 - How I Fixed It
On September 15, 2026, at around 11:52 PM, I thought I had finally finished setting up the CI/CD pipeline for my Project500 application.
I was inside MobaXterm, connected to my AWS EC2 Ubuntu server. I had configured a GitHub Actions self-hosted runner inside:
/home/ubuntu/action-runner/I triggered a test workflow, and the job completed successfully.
The logs showed:
2026-09-15 22:52:44Z: Job serving completed with result: SucceededI was happy.
Then I saw these messages:
Runner listener exit with 0 return code, stop the service, no retry needed.
Exiting runner...The job had succeeded, but the runner process exited instead of remaining available for the next workflow.
If I pushed another commit after that, there was no active runner available to pick up the job. I had to SSH back into the EC2 instance and manually start the runner again.
At that point, I realized something:
I had automated the deployment pipeline, but I was still babysitting the runner.
That was not the kind of automation I wanted.
So I investigated the problem and changed the way I was running the GitHub Actions runner.
What I Was Doing Wrong
When you configure a GitHub Actions self-hosted runner on Linux, you can start it interactively with:
./run.shThis is useful when testing the runner because you can see its output directly in your terminal.
That was how I had initially been running mine.
The problem with this approach for my use case was that I was treating the runner like a temporary interactive process rather than a persistent service.
If the runner process stops, the runner is no longer available to receive new GitHub Actions jobs.
For a CI/CD runner running on an EC2 server, I wanted something more persistent and manageable by the operating system.
GitHub provides a service script for Linux:
./svc.shThis allows the runner to be installed and managed as a systemd service.
That was the change I needed.
The Screenshot That Captured the Problem and the Fix
The screenshot below captures the troubleshooting process from my MobaXterm session.
At the top, the GitHub Actions runner successfully completes the job and then exits.
I then install the runner as a systemd service using:
sudo ./svc.sh installand start it using:
sudo ./svc.sh startThe final output shows the service as:
Loaded: loaded (...; enabled; ...)
Active: active (running)Figure 1: My GitHub Actions self-hosted runner completing a job and exiting, followed by installing and starting it as a systemd service.
This screenshot was useful to me because it shows the actual problem and the steps I took to fix it in the same session.
My EC2 Environment
The runner was running on a small AWS EC2 t3.micro instance.
At the time, I was using the server mainly for testing the Project500 CI/CD pipeline.
My MobaXterm session showed approximately:
RAM: 0.42 GB / 0.89 GB
Root disk usage: 51%
It was a small instance, so I wanted the CI/CD setup to remain lightweight while still being persistent.
The problem wasn't that the EC2 instance couldn't run the runner.
The problem was how I had initially started the runner.
The Fix: Run the Runner as a Systemd Service
After the runner exited, I went back into the action-runner directory and installed it as a system service.
Step 1: Install the Service
I ran:
sudo ./svc.sh installThe output showed:
Creating launch runner in /etc/systemd/system/actions.runner.Sirvickcloud91-project500.cicd-automate.service
Run as user: ubuntu
Run as uid: 1000
gid: 1000
Created symlink /etc/systemd/system/multi-user.target.wants/actions.runner.Sirvickcloud91-project500.cicd-automate.serviceGitHub created a systemd service for my runner.
In my case, the generated service name was:
actions.runner.Sirvickcloud91-project500.cicd-automate.serviceThe service file was created under:
/etc/systemd/system/This allows systemd to manage the GitHub Actions runner as a Linux service.
Step 2: Start the Service
Next, I started the service:
sudo ./svc.sh startThe output showed:
● actions.runner.Sirvickcloud91-project500.cicd-automate.service - GitHub Actions Runner (Sirvickcloud91-project500.cicd-automate)
Loaded: loaded (/etc/systemd/system/actions.runner.Sirvickcloud91-project500.cicd-automate.service; enabled; preset: enabled)
Active: active (running)The two lines I paid the most attention to were:
Loaded: ... enabledand:
Active: active (running)enabled means the service is configured to start automatically when the server boots.
active (running) means the service is currently running.
This was a much better setup for what I wanted.
I no longer needed to manually start the runner every time I wanted it to process a workflow.
How I Check the Runner Status
I can check the service at any time with:
sudo systemctl status actions.runner.Sirvickcloud91-project500.cicd-automate.serviceThis lets me quickly see whether the service is running.
If I want to watch the service logs, I can use:
sudo journalctl -u actions.runner.Sirvickcloud91-project500.cicd-automate.service -fThis is particularly useful when troubleshooting because I can see what the runner is doing instead of guessing.
Managing the Runner Service
Once the runner is installed as a service, I can manage it using the service script.
To stop it:
sudo ./svc.sh stopIf I need to completely remove the service:
sudo ./svc.sh uninstallI would only use uninstall when I actually want to remove the runner service from the server.
What Changed After the Fix?
The biggest change was that I no longer had to treat the GitHub Actions runner as a process I manually started inside an SSH session.
Instead, systemd was managing it as a service.
That is much more appropriate for a server that is supposed to provide CI/CD automation.
My workflow became:
GitHub Repository
↓
GitHub Actions Workflow
↓
Self-Hosted Runner
↓
AWS EC2
↓
Application DeploymentThe runner could remain available on the EC2 server without me sitting in front of an open terminal waiting for the next job.
That was the behavior I wanted.
Why I Eventually Terminated the EC2 Instance
A few days after September 15, I terminated the EC2 instance I had been using for Project500 testing.
The reason was simple:
The cost was becoming unnecessary for a test environment.
The t3.micro instance itself was relatively small, but the overall AWS bill can also include things such as EBS storage and data transfer.
At the time, my CI/CD testing environment was costing me around $14 for the month, which was more than I wanted to continue paying for a test project.
I eventually moved Project500 to a more cost-conscious setup.
I'll share that experience, including what I learned from looking at my actual AWS bill, in another post.
This was another useful lesson for me:
Cloud engineering isn't only about making infrastructure work.
You also have to think about:
Reliability
Monitoring
Security
Resource usage
Cost
What I Learned
The main lesson from this problem wasn't simply:
“Use
svc.sh.”
The bigger lesson was understanding the difference between testing a process manually and running infrastructure as a persistent service.
Initially, I used:
./run.shto run the runner interactively.
That was useful for testing and confirming that the runner worked.
But for my EC2 server, I wanted the runner to be managed as a proper Linux service.
That's where:
sudo ./svc.sh installand:
sudo ./svc.sh startbecame important.
It was a small change, but it made my CI/CD setup much more practical.
Key Takeaway
If you are testing a GitHub Actions self-hosted runner on Ubuntu, you can run it interactively with:
./run.shBut if you want to manage the runner as a persistent service on an EC2 Linux server, you can install it using:
sudo ./svc.sh installThen start it with:
sudo ./svc.sh startAnd verify it with:
sudo systemctl status actions.runner.Sirvickcloud91-project500.cicd-automate.serviceThe important part is understanding what each approach is intended for.
For my Project500 setup, moving from an interactive runner to a systemd-managed service meant I no longer had to manually babysit the runner after every workflow.
That was another small but important lesson in my cloud and DevOps journey.
Automation isn't just about making a deployment happen. It's also about making the infrastructure supporting that automation reliable enough that you don't have to babysit it.
Have you ever had a GitHub Actions self-hosted runner stop unexpectedly? If so, what was causing the problem in your environment?
Read Also: How I Added Datadog Monitoring AWS EC2 Server:
https://blog.sirvickcloud9.online/2026/10/how-i-added-datadog-monitoring-to-my.html
Comments
Post a Comment