1

I've got big troubles with deploy my nuxt.js project on Ubuntu with Nginx;

Ubuntu 18.04 + nginx
Nuxt.js 2.3.2 (universal mode)

So maybe somebody can help me to resolve my problem)

I will to describe all things around this problem below:

My nuxt.conf build part

My nginx config

Then I run this command in ssh

sudo npm run build
sudo pm2 start npm --name "nuxt" -- start

Now server is listening localhost:3000, as I wrote in package.json

After all this I've got 500 error in console, when I open my site. Server error

nginx error.log

2018/11/26 04:48:42 [error] 15032#15032: *5773 upstream prematurely closed connection while reading response header from upstream, client: 173.267.244.9, server: example.com, request: "GET /seller HTTP/1.1", upstream: "http://127.0.0.1:3000/seller", host: "example.com"
2018/11/26 04:48:42 [error] 15032#15032: *5773 connect() failed (111: Connection refused) while connecting to upstream, client: 173.267.244.9, server: example.com, request: "GET /seller HTTP/1.1", upstream: "http://[::1]:3000/seller", host: "example.com"
2018/11/26 04:48:43 [error] 15032#15032: *5773 no live upstreams while connecting to upstream, client: 173.267.244.9, server: example.com, request: "GET /favicon.ico HTTP/1.1", upstream: "http://localhost/favicon.ico", host: "example.com", referrer: "http://example.com/seller"

So now I have no idea whats wrong with that. Help me please.

  • Hello, did you check in nginx error / access logs ? – DependencyHell Nov 24 '18 at 14:11
  • Now it gives 502 Bad getaway – Baikal Irkutsk Nov 26 '18 at 01:49
  • My error logs: 2018/11/26 04:48:42 [error] 15032#15032: *5773 upstream prematurely closed connection while reading response header from upstream, client: 173.267.244.9, server: example.com, request: "GET /seller HTTP/1.1", upstream: "http://127.0.0.1:3000/seller", host: "example.com" – Baikal Irkutsk Nov 26 '18 at 01:51
  • 2018/11/26 04:48:42 [error] 15032#15032: *5773 connect() failed (111: Connection refused) while connecting to upstream, client: 173.267.244.9, server: example.com, request: "GET /seller HTTP/1.1", upstream: "http://[::1]:3000/seller", host: "example.com" – Baikal Irkutsk Nov 26 '18 at 01:52
  • 2018/11/26 04:48:43 [error] 15032#15032: *5773 no live upstreams while connecting to upstream, client: 173.267.244.9, server: mysite.com, request: "GET /favicon.ico HTTP/1.1", upstream: "http://localhost/favicon.ico", host: "example.com", referrer: "http://example.com/seller" – Baikal Irkutsk Nov 26 '18 at 01:54
  • Did you ever find a solution for this problem? – AntonyMN Aug 13 '21 at 14:08

1 Answers1

0

It seems that Nginx tries to connect on the IPv6 loopback [::1], and nodejs is probably just listening on IPv4.

Try setting 127.0.0.1 instead of localhost

DependencyHell
  • 1,027
  • 15
  • 22