Question

Server at 127.0.0.1:3001 (sub domain) is not working, 127.0.0.1:3000 (main) is working fine.

Hello everyone. Currently I am deploying the site to the vps. I successfully ran the nextjs app in home directory(domain.com) in 127.0.0.1:3000 but the PERN stack app in admin.domain.com.au, the frontend is working right, but it seem the server at 127.0.0.1:3001 is not working(I tried netstat -plant | grep 3001 command and it doesn’t show up).

error log:

[error] 56833#56833: *57 connect() failed (111: Connection refused) while connecting to upstream, client: 110.44.115.155, server: admin.domain.com, request: "POST /api/users/login HTTP/1.1", upstream: "http://127.0.0.1:3001/api/users/login", host: "admin.domain.com", referrer: "http://admin.domain.com/login"
2022/10/06 18:05:05 [error] 56833#56833: *65 connect() failed (111: Connection refused) while connecting to upstream, client: 110.44.115.155, server: admin.domain.com, request: "POST /api/users/login HTTP/1.1", upstream: "http://127.0.0.1:3001/api/users/login", host: "admin.domain.com", referrer: "http://admin.domain.com/login"

nginx configure file:

server {
        listen 80;
        listen [::]:80;

         root /var/www/admindomain/frontend/build;

        # Add index.php to the list if you are using PHP
        index index.html index.htm index.nginx-debian.html;

        server_name admin.domain.com www.admin.domain.com;

        location / {
                try_files $uri /index.html;
        }

         location /api {
            proxy_pass http://127.0.0.1:3001;
            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;
        }

}

Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

KFSys
Site Moderator
Site Moderator badge
October 7, 2022
Accepted Answer

Hi @heysuneel,

Well, it does seem like the app itself cant start on port 3001. When you launch that app do you see any errros in the Apps logs except in Nginx logs? The Nginx one:

  1. 2022/10/06 18:05:05 [error] 56833#56833: *65 connect() failed (111: Connection refused)

You see should be related to the App not starting so you need to check your APPs log and see if you can find out the error behind it failing to start

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel