I established backend on Ubuntu 20.04 with pm2 command.
Here is the log when I use yarn start
:
pm2 launched in no-daemon mode (you can add DEBUG="*" env variable to get more messages)
2023-03-25T00:04:04: PM2 log: Launching in no daemon mode
2023-03-25T00:04:04: PM2 log: [PM2][WARN] Applications app not running, starting...
2023-03-25T00:04:04: PM2 log: App [app:0] starting in -cluster mode-
2023-03-25T00:04:04: PM2 log: App [app:0] online
2023-03-25T00:04:04: PM2 log: [PM2] App [app] launched (1 instances)
2023-03-25T00:04:04: PM2 log: ┌────┬────────────────────┬──────────┬──────┬───────────┬──────────┬──────────┐
│ id │ name │ mode │ ↺ │ status │ cpu │ memory │
├────┼────────────────────┼──────────┼──────┼───────────┼──────────┼──────────┤
│ 0 │ app │ cluster │ 0 │ online │ 0% │ 38.4mb │
└────┴────────────────────┴──────────┴──────┴───────────┴──────────┴──────────┘
2023-03-25T00:04:04: PM2 log: [--no-daemon] Continue to stream logs
2023-03-25T00:04:04: PM2 log: [--no-daemon] Exit on target PM2 exit pid=57468
00:04:05 0|app | 2023-03-25T00:04:05: mongo::: mongodb://localhost/development-database
Also here is config detail:
NODE_ENV=development
PORT=8001
JWT_SECRET=0a6b944d-d2fb-46fc-a85e-0295c986cd9f
JWT_EXPIRES_IN=1440
MONGO_HOST=mongodb://localhost/development-database
MONGO_PORT=27017
MONGOOSE_DEBUG=true
And I allowed ports and firewall. Here is the status:
ubuntu@ip-172-31-7-168:~/simple_betting_backend$ sudo ufw status verbose
Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing), disabled (routed)
New profiles: skip
To Action From
-- ------ ----
80 ALLOW IN Anywhere
80/tcp (Nginx HTTP) ALLOW IN Anywhere
22 ALLOW IN Anywhere
8000 ALLOW IN Anywhere
80/tcp ALLOW IN Anywhere
80 (v6) ALLOW IN Anywhere (v6)
80/tcp (Nginx HTTP (v6)) ALLOW IN Anywhere (v6)
22 (v6) ALLOW IN Anywhere (v6)
8000 (v6) ALLOW IN Anywhere (v6)
80/tcp (v6) ALLOW IN Anywhere (v6)
But when I access to http://serverIP:8000/api/betting, it doesn't work.
Can anyone solve this problem to help me?