First I found out that there was no firewall attached to the droplet. Then I attached a firewall rule to it. But, after that I got Error: 502 Bad Gateway nginx/1.14.0 (Ubuntu)
Here are error logs of /var/log/nginx/error.log:
2020/10/30 04:30:33 [error] 966#966: *28 connect() failed (111: Connection refused) while connecting to upstream, client: 71.85.115.26, server: _, request: "POST /editBlackAndWhiteList HTTP/1.1", upstream: "http://127.0.0.1:1338/editBlackAndWhiteList", host: "159.203.49.172"
2020/10/30 04:32:04 [error] 966#966: *30 connect() failed (111: Connection refused) while connecting to upstream, client: 122.117.89.127, server: _, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:1338/", host: "127.0.0.1"
Also, the result of sudo nginx -t is:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
I checked whether nginx is running systemctl status nginx:
● nginx.service - A high performance web server and a reverse proxy serv
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor pr
Drop-In: /etc/systemd/system/nginx.service.d
└─override.conf
Active: active (running) since Fri 2020-10-30 03:34:28 UTC; 1h 12min
Docs: man:nginx(8)
Process: 964 ExecStartPost=/bin/sleep 0.1 (code=exited, status=0/SUCCE
Process: 960 ExecStart=/usr/sbin/nginx -g daemon on; master_process on
Process: 897 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_p
Main PID: 963 (nginx)
Tasks: 2 (limit: 2361)
CGroup: /system.slice/nginx.service
├─963 nginx: master process /usr/sbin/nginx -g daemon on; mas
└─966 nginx: worker process
Running ps auxf | grep nginx gives:
root 20160 0.0 0.0 14856 984 pts/0 S+ 04:48 0:00 | \_ grep --color=auto nginx
root 963 0.0 0.0 141120 1544 ? Ss 03:34 0:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
www-data 966 0.0 0.3 143792 6252 ? S 03:34 0:00 \_ nginx: worker process
Running ufw status gives:
ufw status
Status: active
To Action From
-- ------ ----
Nginx HTTP ALLOW Anywhere
OpenSSH ALLOW Anywhere
1337/tcp ALLOW Anywhere
3306 ALLOW Anywhere
Nginx HTTP (v6) ALLOW Anywhere (v6)
OpenSSH (v6) ALLOW Anywhere (v6)
1337/tcp (v6) ALLOW Anywhere (v6)
3306 (v6) ALLOW Anywhere (v6)
Here is my file /etc/nginx/nginx.conf:
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}
How can I make my server run? Any help will be appreciated
Also, my project is in /var/www/project:
README.md config/ node_modules/ public/
admin/ ecosystem.config.js package-lock.json server.sh*
api/ extensions/ package.json yarn-error.log
build/ favicon.ico podcasting.sql yarn.lock
Running npm start gives:
[2020-10-30T04:53:56.719Z] debug ⛔️ Server wasn't able to start properly.
[2020-10-30T04:53:56.728Z] error TypeError: Cannot convert undefined or null to object
at Function.values (<anonymous>)
at Object.load (/var/www/project/node_modules/strapi-database/lib/connector-registry.js:17:39)
at DatabaseManager.initialize (/var/www/project/node_modules/strapi-database/lib/database-manager.js:32:21)
at Strapi.load (/var/www/project/node_modules/strapi/lib/Strapi.js:311:19)
at async Strapi.start (/var/www/project/node_modules/strapi/lib/Strapi.js:190:9)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! podcasting@0.1.0 start: `strapi start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the podcasting@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-10-30T04_53_56_766Z-debug.log
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!
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.
Hi there @buckyrobertsx,
As far as I can see the Nginx configuration looks good and the Nginx service is up and running.
The problem seems to be your backend application. As I can see that you are using Strapi, I would recommend following the steps from the official Strapi Documentation here on how to get it up and running on DigitalOcean:
https://strapi.io/documentation/v3.x/deployment/digitalocean.html
Let me know how it goes! Regards, Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.
