I’m encountering a 502 Bad Gateway error when trying to open our custom app in the Shopify store. The app is built using Remix and is hosted on Google Cloud Platform (GCP). Here are the steps we have taken so far:
We restarted the Compute Engine instance on GCP.
We also restarted the Nginx server.
However, the error persists. Below are some additional details:
The Nginx configuration file (/etc/nginx/nginx.conf) seems standard, and includes configurations from /etc/nginx/conf.d/.conf and /etc/nginx/sites-enabled/.
The application is supposed to run on port 8080.
Here is a snippet from our Nginx error log:
2024/07/19 15:18:24 [error] 12503#12503: *47 no live upstreams while connecting to upstream, client: 103.251.255.124, server: app.agencyai.app, request: “GET /?embedded=1&hmac=23b9e76fb39ddf329dfd7d76f4cdd13331aeb5311a0979ed4a2f3edd0ec5d8ae&host=YWRtaW4uc2hvcGlmeS5jb20vc3RvcmUvaW1wZXJpYWwtZGF0YS1zdXBwbHk&id_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczpcL1wvaW1wZXJpYWwtZGF0YS1zdXBwbHkubXlzaG9waWZ5LmNvbVwvYWRtaW4iLCJkZXN0IjoiaHR0cHM6XC9cL2ltcGVyaWFsLWRhdGEtc3VwcGx5Lm15c2hvcGlmeS5jb20iLCJhdWQiOiIyOWFiODgwMDQwMzg1NWVjOTllMzAxYmRmMzRkNDc4ZSIsInN1YiI6Ijg4NDU0MzY1MzYzIiwiZXhwIjoxNzIxNDAyMzYzLCJuYmYiOjE3MjE0MDIzMDMsImlhdCI6MTcyMTQwMjMwMywianRpIjoiY2E3ZGYxMjItNmE3YS00NTY2LWE4NTUtMjc3MzAxYThmMDYxIiwic2lkIjoiYzAzYThkNmUtZWU3Ni00ZmViLTg5ZWQtN2YxYTdlZDdhNWNkIiwic2lnIjoiMTdjNmQ4MDZjZmI0ZDdiNGYzMmQwMzI2NmZiYjcwYWVkZjQ1NWEwNTE2ODQwY2VhYTU0YWE1ODJiZWVlMTA2OCJ9.A5Q0JJossokUhjNeafaXr_bD1tDKw7FCZAwpvlyHUq4&locale=en-CA&session=1d943e75b72dd40b3c2482d1bf17490788bf3818abba28d4da16bc3fd45f4185&shop=imperial-data-supply.myshopify.com×tamp=1721402303 HTTP/1.1”, upstream: “http://localhost/?embedded=1&hmac=23b9e76fb39ddf329dfd7d76f4cdd13331aeb5311a0979ed4a2f3edd0ec5d8ae&host=YWRtaW4uc2hvcGlmeS5jb20vc3RvcmUvaW1wZXJpYWwtZGF0YS1zdXBwbHk&id_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczpcL1wvaW1wZXJpYWwtZGF0YS1zdXBwbHkubXlzaG9waWZ5LmNvbVwvYWRtaW4iLCJkZXN0IjoiaHR0cHM6XC9cL2ltcGVyaWFsLWRhdGEtc3VwcGx5Lm15c2hvcGlmeS5jb20iLCJhdWQiOiIyOWFiODgwMDQwMzg1NWVjOTllMzAxYmRmMzRkNDc4ZSIsInN1YiI6Ijg4NDU0MzY1MzYzIiwiZXhwIjoxNzIxNDAyMzYzLCJuYmYiOjE3MjE0MDIzMDMsImlhdCI6MTcyMTQwMjMwMywianRpIjoiY2E3ZGYxMjItNmE3YS00NTY2LWE4NTUtMjc3MzAxYThmMDYxIiwic2lkIjoiYzAzYThkNmUtZWU3Ni00ZmViLTg5ZWQtN2YxYTdlZDdhNWNkIiwic2lnIjoiMTdjNmQ4MDZjZmI0ZDdiNGYzMmQwMzI2NmZiYjcwYWVkZjQ1NWEwNTE2ODQwY2VhYTU0YWE1ODJiZWVlMTA2OCJ9.A5Q0JJossokUhjNeafaXr_bD1tDKw7FCZAwpvlyHUq4&locale=en-CA&session=1d943e75b72dd40b3c2482d1bf17490788bf3818abba28d4da16bc3fd45f4185&shop=imperial-data-supply.myshopify.com×tamp=1721402303”, host: “app.agencyai.app”, referrer: “”
The nginx.conf file includes:
server {
listen 80;
server_name app.agencyai.app;
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;
}
}
We have verified that the application is supposed to be running on port 8080. Here are the additional troubleshooting steps we have taken:
Ensured the application server is running and listening on port 8080.
Checked firewall and security group rules to ensure port 8080 is open.
Verified the Nginx configuration and tested it with nginx -t.
Despite these steps, the issue persists. Any insights or suggestions on resolving this issue would be greatly appreciated.
Thank you!
What We Tried
Restarted the Compute Engine instance on GCP.
Restarted the Nginx server using the following commands:
sudo systemctl restart nginx
Verified that the application is supposed to run on port 8080.
Checked if the application server is running and listening on port 8080:
sudo netstat -tuln | grep 8080
We expected to see the application listening on port 8080, but it wasn’t.
Verified firewall and security group rules to ensure port 8080 is open.
Tested Nginx configuration to ensure there are no syntax errors:
sudo nginx -t
Monitored Nginx error logs to identify the issue.
What We Expected
We expected the custom Shopify app to load successfully without the 502 Bad Gateway error after restarting the services and verifying the configurations. We expected the application to be accessible through Nginx, indicating that it is correctly proxied to the backend application server running on port 8080.
Issue
Despite the above steps, the error persists, and the application remains inaccessible. The logs indicate a failure to connect to the upstream server, suggesting that either the application server is not running, not listening on the correct port, or there’s a misconfiguration in the Nginx setup.
Any insights or suggestions on resolving this issue would be greatly appreciated.
Muscled PM is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.