Reputation: 13
I'm running very simple express website on Azure shared resource in Australia Southeast region. Website run locally on port 3000 however when deployed to Azure doesnt render at all. When try to run from Azure throws below error
node server.js
events.js:141
throw er; // Unhandled 'error' event
Error: listen EADDRINUSE 0.0.0.0:3000
at Object.exports._errnoException (util.js:874:11)
at exports._exceptionWithHostPort (util.js:897:20)
at Server._listen2 (net.js:1234:14)
at listen (net.js:1270:10)
at Server.listen (net.js:1366:5)
at EventEmitter.listen (D:\home\site\wwwroot\node_modules\express\lib\application.js:617:24)
at Object.<anonymous> (D:\home\site\wwwroot\server.js:21:5)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
Server.js looks like
var express = require('express');
var app = express();
var path = require("path");
var port = process.env.PORT || 3000;
console.log(__dirname);
app.use(express.static('public'));
app.get('/', function (req, res) {
res.sendFile(path.join(__dirname+'/index.html'));
});
app.get('/contact', function (req, res) {
res.sendFile(path.join(__dirname+'/contact.html'));
});
app.listen(port, function () {
console.log('Example app listening on port!' + port);
});
Not sure what am I missing?
Thanks
Upvotes: 1
Views: 1978
Reputation: 24128
Azure website allows hosting of node.js application via IIS module called iisnode. Please see the wiki for iisnode to know it.
Especially note the content below.
Minimal changes to node.js application code. The iisnode module enables hosting of existing HTTP node.js applications with very minimal changes. Typically all that is required is to change the listed address of the HTTP server to one provided by the iisnode module via the process.env.PORT environment variable.
So you don't need to start up the node app via command node server.js
manually in Kudu Console. Please try to only deploy or update the code via FTP or VS, and directly access the website to check the deployment successfully. You can try to restart the application on Azure portal if it not works.
If you want to check the running process, you can see them in the Process explorer
of Kudu tool, please see the figure below.
Any concern, please feel free to let me know.
Upvotes: 1
Reputation: 531
It means the port you are trying to bind the server to is in use. Try another port or close the program using that port on azure.
Upvotes: 0
Reputation: 469
Ok,
This may be due to you have already running an instance of node on 3000. go to terminal interface using ssh connection to your server.invoke this command.
ps -ax | grep Server.js
a list of running process will be there like
get 1257 from there and on terminal
kill 1257
now try to run your server again.
Upvotes: 0