AWS Builder Center
EC2 Is Running, But Your Website Isn't Opening? 6 Checks to Fix It

EC2 Is Running, But Your Website Isn't Opening? 6 Checks to Fix It

Learn how to troubleshoot an EC2 website that won't open. Check security groups, Nginx, PM2, application ports, build errors, and server logs.

EC2 Is Running, But Your Website Isn't Opening? 6 Checks to Fix It

One of the confusing situations when deploying a website on AWS EC2 is seeing your instance in the Running state while your website refuses to open.
You launch an Ubuntu instance, install Node.js, deploy your application, configure Nginx, and start the server.
Everything seems fine.
But when you open your website, you get:
  • ERR_CONNECTION_REFUSED
  • 502 Bad Gateway
  • 504 Gateway Timeout
  • A website that keeps loading without responding
The important thing to understand is that an EC2 instance being healthy does not necessarily mean your application is working.
Here are six checks I recommend when troubleshooting a Node.js or Next.js application deployed on Ubuntu EC2.

1. Check Your EC2 Security Group

Start with the network configuration.
Security Groups control inbound and outbound traffic to your EC2 instance.
For a typical website, check whether the required inbound rules exist:
Type
Port
Purpose
SSH
22
Server administration
HTTP
80
Website access
HTTPS
443
Secure website access
For SSH, restrict access to your own IP address whenever possible. Avoid opening SSH to everyone.
For public websites, allow HTTP and HTTPS traffic as required.
Useful tip: If your website is inaccessible, don't immediately change application code. First verify that traffic can reach your server.

2. Check Whether Your Application Is Running

Your EC2 instance may be running while your Node.js application has stopped.
If you're using PM2, run:
pm2 status
This shows your managed application processes.
To inspect errors:
pm2 logs
If your application has stopped, investigate the logs before restarting it.
You can restart a specific application using:
pm2 restart app-name
Don't blindly restart repeatedly. The logs may reveal the actual problem.

3. Check Whether Your Application Port Is Listening

Suppose your Next.js application should run on port 3000.
Check whether that port is listening:
sudo ss -ltnp
You can also test the application locally:
curl -I http://localhost:3000
If the application responds locally but your public website doesn't open, investigate Nginx and the network configuration.
If it doesn't respond locally, investigate the application process and its configuration first.
Remember: Your application does not always need to be publicly accessible on port 3000. With Nginx acting as a reverse proxy, you can keep the application port private.

4. Check Your Nginx Configuration

Nginx is commonly used as a reverse proxy in front of Node.js applications.
A typical request flow looks like this:
User → Nginx (Port 80/443) → Next.js (Port 3000)
Check whether Nginx is running:
sudo systemctl status nginx
Test the configuration:
sudo nginx -t
If the configuration is valid, reload Nginx:
sudo systemctl reload nginx
If you receive a 502 Bad Gateway error, check whether Nginx can communicate with your application on the configured upstream address and port.

5. Check Your Application Build

This is particularly important for Next.js deployments.
A development server and a production server are not the same.
For a typical Next.js application, the production workflow includes:
npm install
npm run build
npm run start
If the build fails, the production application may not start correctly.
Check for errors such as:
  • Missing dependencies
  • Incorrect environment variables
  • TypeScript or compilation errors
  • Missing production build output
  • Incorrect start scripts
Don't assume that a successful dependency installation means your application is ready for production.

6. Inspect Server and Application Logs

When the cause is still unclear, logs are your best friend.
For Nginx:
sudo tail -n 50 /var/log/nginx/error.log
For PM2:
pm2 logs
For the Nginx system service:
sudo journalctl -u nginx -n 50
Look for connection errors, missing files, permission problems, failed builds, and application crashes.
Instead of changing several configurations at once, identify the error, make one controlled change, and test again.

My EC2 Troubleshooting Checklist

Whenever a website stops responding, I would follow this order:
  1. Is the EC2 instance running?
  1. Are the Security Group rules correct?
  1. Is the application process running?
  1. Is the expected application port listening?
  1. Is Nginx running and configured correctly?
  1. Did the application build successfully?
  1. What do the application and server logs report?
This approach helps narrow down the issue without randomly changing the server configuration.

Final Thoughts

Deploying an application is not just about making it accessible once. It is also about understanding how to diagnose problems when something goes wrong.
EC2, Ubuntu, Node.js, PM2, and Nginx work together, and a failure in any one of these layers can affect the entire website.
The most important troubleshooting lesson is simple:
Don't just check whether your server is running. Check whether your application can actually serve requests.

Let's discuss!

Have you ever deployed a website on EC2 that worked perfectly at first but suddenly stopped opening?
What was the actual issue: Security Groups, Nginx, PM2, application errors, or something else?
Share your experience. It might help another developer solve the same problem!
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article