Score:0

Can't access to express backend apis which is running on ubuntu server

bz flag

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?

in flag
Silly question, but your config says `PORT=8001`, but your browser is being pointed to 8000. Is one of these values incorrect?
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.