Node.js - Nginx 502 Bad Gateway on POST/PUT


I have a MEAN app and on localhost works fine.

I have a CentOs droplet with node.js and nginx, but that i make for example a submit form by POST or PUT, console returns “502 Bad Gateway”.

Each time i restart nginx, shows: nginx: [emerg] unknown directive “proxy_http_version”

My conf in nginx:

server {
    listen 80;
    location / {
        proxy_pass http://localhost:3003;
        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;
        proxy_connect_timeout       300;
        proxy_send_timeout          300;
        proxy_read_timeout          300;
        send_timeout                300;

My niginx version is 1.0.15

Thanks for now. =D

Show comments

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

This question was answered by @vegardx

Since you’re doing proxypass to localhost it will be whatever resolves to localhost in your /etc/hosts-file that makes it bind to that interface. Change out localhost with in your proxypass and you’ll pass it only to

This comment has been deleted