I have a Node.js/Express.js app running on my server that only works on port 3000 and I\'m trying to figure out why. Here\'s what I\'ve found:
If you want to show something you're connected on 3000
var express = require('express')
var app = express()
app.get('/', function (req, res) {
res.send('Hello World!')
})
app.listen(3000, function () {
console.log('Example app listening on port 3000!')
})
I hope that will be helpful to you
If you are using Nodemon my guess is the PORT 3000 is set in the nodemonConfig. Check if that is the case.
In bin/www
, there is a line:
var port = normalizePort(process.env.PORT || '3000');
Try to modify it.
Make sure you are running from that folder of your application, where you have the package.json.