Reputation: 634
I am trying to host this Github repository on Ubuntu 16 with Nginx. But I am getting 502 bad request error. For deploying the express js app, I have followed this Digital Ocean tutorial. I have cloned the repo in home directory and installed pm2. I have also started my app using pm2 start app.js
and it is working. Here is the my pm2 status:
I have also configured Nginx proxy server according to the mentioned Digital Ocean tutorial. My configuration file (Location: /etc/nginx/sites-available/default) is as below:
# Default server configuration
#
server {
listen 80 default_server;
listen [::]:80 default_server;
#root /var/www/html;
root /home/ubuntu/blockchain-demo/routes;
# Add index.php to the list if you are using PHP
index index.js index.html index.htm index.nginx-debian.html;
server_name 54.255.173.175; #this is my public IP. I don't have domain.
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
The Nginx error log is as follows:
2018/10/15 15:38:13 [error] 6283#6283: *5 connect() failed (111: Connection refused) while connecting to upstream, client: 27.147.204.239, server: 54.255.173.175, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "54.255.173.175"
2018/10/15 15:38:14 [error] 6283#6283: *5 connect() failed (111: Connection refused) while connecting to upstream, client: 27.147.204.239, server:54.255.173.175, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:3000/favicon.ico", host: "54.255.173.175", referrer:http://54.255.173.175/"
I have googled and found different solution. One of the solution suggested to check the localhost:3000 port. Here is my localhost port report:
Can anyone help me to figure out where is the problem that causes the error? Thanks in advance.
Upvotes: 1
Views: 1723