Server cannot recognize POST request

Posted January 21, 2021 836 views
NginxMongoDBNode.jsUbuntu 20.04

I’ve deployed an express API on a droplet and now I cannot POST to the API. When I try it says cannot GET /route when I POST from postman.

Thank you in advance!

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.

Submit an Answer
1 answer

Hi there,

This sounds like there might be a problem with the Nginx configuration.

I could suggest using the Nginx configuration from this tutorial here:

If this still does not work, I would suggest chacking your Nginx error log for some more information and also possibly sharing your Nginx configuration here.


by Brennen Bearnes
Node.js is an open source JavaScript runtime environment for easily building server-side and networking applications. Node.js applications can be run at the command line but this guide focuses on running them as a service using PM2, so that they will automatically restart on reboot or failure, and can safely be used in a production environment.
  • Thanks for your prompt reply Bobby,

    Yeah! I’ve followed that tutorial and I’m using the exact same configuration posted there + Lets encrypt but it does not work. It works internally when I post the API as localhost. This is the Nginx config,(Please note that the server responds to GET requests normally)

    . . .
        location / {
            proxy_pass http://localhost: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;
    edited by bobbyiliev
    • Hi there,

      If you have an SSL certificate with a http to https redirect, you might have to run the POST request directly to the https version of your website.

      If this does not help, I could suggest checking your access and error logs with:

      tail -100 /var/log/nginx/error.log
      tail -100 /var/log/nginx/access.log

      This should give you some more information on what could be going wrong.

      Feel free to share the logs here as well.