How to Use Port 8080 on a VPS: Complete Configuration Guide
Check If Port 8080 Is Open on Your VPS
Before configuring anything, check the current state of port 8080 from both inside and outside your VPS.
For closely related port / network-diagnostic topics, see What Is Port 8080 Used For?, How to Use portquiz.net to Test Port 8080, and https://localhost:110501 — Fix Invalid Port Error.
Check from Inside the VPS (Local Listening)
See if any service is already using port 8080:
sudo ss -tlnp | grep :8080
# OR
sudo netstat -tlnp | grep :8080
If a service is listed (e.g., java, nginx), port 8080 is already in use. If there's no output, the port is free.
Check from Outside (Remote Connectivity)
From your local computer, test if the port is accessible through the VPS's public firewall:
nc -zv YOUR_VPS_PUBLIC_IP 8080
Interpretation:
- Success:
Connection to YOUR_VPS_IP 8080 port [tcp/http-alt] succeeded! - Failure (Connection refused): No service is listening, or the VPS's local firewall is blocking it.
- Failure (Timeout): The cloud provider's network firewall (security group) is likely blocking the port.
Open Port 8080 in the Firewall
There are typically two layers of firewalls to configure on a VPS: the system firewall (UFW, firewalld, iptables) and the cloud provider's firewall (Security Groups, Firewall Rules).
1. System Firewall Configuration
Allow Port 8080 in UFW (Ubuntu/Debian):
sudo ufw allow 8080/tcp
sudo ufw reload
sudo ufw status verbose # Verify rule
You should see: 8080/tcp ALLOW IN Anywhere
Allow Port 8080 in Firewalld (CentOS/RHEL/AlmaLinux):
sudo firewall-cmd --add-port=8080/tcp --permanent
sudo firewall-cmd --reload
sudo firewall-cmd --list-ports # Check active ports
2. Cloud Provider Firewall (CRITICAL STEP)
Most VPS providers (EraHost, AWS, DigitalOcean, Linode) have an external firewall that overrides your system firewall. You must configure it in your hosting control panel.
- EraHost Cloud VDS: Navigate to your VPS management panel, find "Firewall Rules" or "Security Groups," and add an Inbound rule for TCP port 8080 from source
0.0.0.0/0(all IPs) or a specific IP range. - General Process: Locate the firewall/network settings for your VPS, add a new rule for TCP port 8080, and apply it.
0.0.0.0/0 makes it publicly accessible to the entire internet. For administrative interfaces (like Jenkins), consider restricting the source IP to your office or home IP address (YOUR_IP/32).
Run a Web Server on Port 8080
Once the firewall is open, configure your application to listen on port 8080.
Configure Apache to Use Port 8080
- Edit the ports configuration file:
sudo nano /etc/apache2/ports.conf # Ubuntu/Debian # OR sudo nano /etc/httpd/conf/httpd.conf # CentOS/RHEL - Ensure a
Listendirective exists for port 8080:Listen 8080 - Configure a virtual host to use this port. Edit your site config (e.g.,
/etc/apache2/sites-available/000-default.conf):<VirtualHost *:8080> ServerAdmin admin@yourdomain.com ServerName yourdomain.com DocumentRoot /var/www/html # ... other directives </VirtualHost> - Enable the configuration and restart:
sudo a2ensite your-site-config # If needed sudo systemctl restart apache2 # Ubuntu/Debian # OR sudo systemctl restart httpd # CentOS/RHEL
Configure Nginx to Use Port 8080
- Edit your site configuration:
sudo nano /etc/nginx/sites-available/your-site - Modify or create a server block:
server { listen 8080; server_name yourdomain.com; root /var/www/html; index index.html index.php; location / { try_files $uri $uri/ =404; } # Additional configuration for PHP, etc. } - Test the configuration and restart:
sudo nginx -t sudo systemctl restart nginx
Run a Simple Test Server (Python)
For a quick test, you can run a temporary HTTP server:
python3 -m http.server 8080 --bind 0.0.0.0
This starts a basic server in the current directory, accessible on port 8080.
Test Access to Port 8080
After configuration, verify everything works.
- Check local listening:
You should see your service (nginx, apache, java, python) listening onsudo ss -tlnp | grep :8080*:8080or0.0.0.0:8080. - Test from your local machine:
A successful response showscurl -I http://YOUR_VPS_IP:8080HTTP/1.1 200 OKor similar. - Access via browser: Open
http://YOUR_VPS_IP:8080in a web browser. You should see your application or a default web page.
Configure Port Forwarding (If Needed)
If you want users to access your service on the standard HTTP port (80) but internally it runs on 8080, set up port forwarding.
Using iptables (Simple Redirect)
sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
To make this rule permanent on Ubuntu/Debian:
sudo apt-get install iptables-persistent -y
sudo netfilter-persistent save
Using Nginx as a Reverse Proxy (Recommended)
This is more flexible and allows SSL termination. Create an Nginx config listening on port 80:
server {
listen 80;
server_name yourdomain.com www.yourdomain.com;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
sudo nginx -t
sudo systemctl restart nginx
Now visitors to http://yourdomain.com will be served by the application on port 8080.
Common Applications Using Port 8080
| Application | Configuration Note |
|---|---|
| Apache Tomcat | Edit /opt/tomcat/conf/server.xml, find the <Connector port="8080"> directive. |
| Jenkins | Set HTTP_PORT=8080 in /etc/default/jenkins or start with java -jar jenkins.war --httpPort=8080. |
| Node.js (Express) | In your app: app.listen(8080, '0.0.0.0'). |
| Docker Container | Run with: docker run -p 8080:80 image_name to map container port 80 to host port 8080. |
Summary
| Task | Command / Key Action |
|---|---|
| Check local port usage | sudo ss -tlnp | grep :8080 |
| Test external connectivity | nc -zv VPS_IP 8080 (from your local PC) |
| Allow port in UFW | sudo ufw allow 8080/tcp |
| Allow port in Firewalld | sudo firewall-cmd --add-port=8080/tcp --permanent |
| Configure Cloud Firewall | Most Important: Add inbound rule for TCP 8080 in your VPS provider's control panel. |
| Apache on port 8080 | Add Listen 8080 in ports.conf; configure virtual host for *:8080. |
| Nginx on port 8080 | Set listen 8080; in server block. |
| Test final access | Visit http://VPS_IP:8080 in a browser. |
| Forward port 80 to 8080 | Use iptables redirect or Nginx reverse proxy configuration. |
localhost:8080.
Your VPS is now correctly configured to use port 8080 for web applications, development servers, or any other service you choose to run.


