expressjs / express

Fast, unopinionated, minimalist web framework for node.
https://expressjs.com
MIT License
65.81k stars 16.46k forks source link

NuxtServerError: connect ECONNREFUSED ip:80 #3487

Closed duqigit closed 7 years ago

duqigit commented 7 years ago

9gf nfv 5 w2razo1 rm

dougwilson commented 7 years ago

Hi! In order to debug through your issue, please provide all the following information:

  1. Version of Node.js
  2. Version of Express
  3. Complete code that has the issue we can copy and paste and run
  4. Complete instructions on how to reproduce the issue

Thanks!

duqigit commented 7 years ago

Thanks

Node.js Version :v9.2.0 express Version :4.15.3

servier.js

import express from 'express' import { Nuxt, Builder } from 'nuxt'

import api from './api'

const app = express() const host = process.env.HOST || '106.14.133.247' const port = process.env.PORT || 80

app.set('port', port)

// Import API Routes app.use('/api', api)

// Import and Set Nuxt.js options let config = require('../nuxt.config.js') config.dev = !(process.env.NODE_ENV === 'production')

// Init Nuxt.js const nuxt = new Nuxt(config)

// Build only in dev mode if (config.dev) { const builder = new Builder(nuxt) builder.build() }

// Give nuxt middleware to express app.use(nuxt.render) // Listen the server app.listen(port) console.log('Server listening on ' + host + ':' + port) // eslint-disable-line no-console

and Listen :3000 is ok: 5 7 bns9e mvx2 e g0

but Listen :80is error: zo daop2 jm6mxp5_ f b

duqigit commented 7 years ago

@dougwilson

dougwilson commented 7 years ago

I'm not sure I understand. If it works fine on 3000, but then you change the server code to lusten on port 80, then of course you'll get an error when you now try to connect to port 3000. You need yo connect to port 80 if you listen on port 80.

duqigit commented 7 years ago

What do I need to do? @dougwilson

chanlito commented 7 years ago

@18717700273 if you want to listen on port 80, you should use a reverse proxy like nginx to do it.

dougwilson commented 7 years ago

This seems to be from the nuxt.js you are using, and not related to Express. I suggest either removing nuxt.js or posting on the nuxt.js support. From your screenshot you are connecting to port 80 fine but then something in nuxt.js is still trying to connect to port 3000.