skip to Main Content

js website , everything is good in local system while i am using the port 3200 and 80 , When i deployed the code to the godaddy vps linux Server i am getting errors

Error: listen EACCES : PERMISSION denied 0.0.0.0.80 ###

while using port 80 or 443 instead of 3000 in godaddy vps linux server


console.log('Welcome to Node Server... ');

var process = require('process');
var http = require('http');
var https = require('https');
var url = require('url');


const mysql = require('mysql');
const express = require('express');
// var router = express.Router();
const app = express();
const bodyParser = require('body-parser');
const path = require('path');
const fs = require('fs');
const multer = require('multer');

app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());



var connection = require('./db.js');
const cors = require('cors');
// app.use(cors())
// app.use(cors({ origin: "http://localhost:4200", credentials: true }));



app.use((req, res, next) => { res.send('<h1>Hello from HowTags!!!</h1>'); });

const options = {
  // key: fs.readFileSync('server.key'),
  // cert: fs.readFileSync('server.cert'),
  cert: fs.readFileSync('./ssl/7f16b8c7268c5ae5.crt'),
  // key: fs.readFileSync('./ssl/generated-private-key.txt'),
  pem: fs.readFileSync('./ssl/7f16b8c7268c5ae5.pem'),
};



http.createServer(app).listen(80, null, null, () => { console.log('Server started listening on port ' + 80); });

https.createServer(options, app).listen(443, null, null, () => { console.log('Server started listening on port ' + 443); });

// Code Ends ..................................................

i am also tried with .htaccess re-directions but it will not working

RewriteEngine On

 RewriteRule ^$ http://howtags.com:8000 [P,L]
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule ^(.*)$ https://howtags.com:443$1 [P,L]
 RewriteRule (.*) http://howtags.com:80/$1 [L,P,QSA]   

+++++++++++++++++++++++++
PassengerBaseURI /
PassengerAppRoot /home/howtags/howtags/node
PassengerAppType node
PassengerStartupFile index.js

if anyone find anything wrong in the code please tell me …
if anyone know better solution please tell me ….

2

Answers


  1. Chosen as BEST ANSWER

    I found the solution by using NGINX

    follow the below link for more information about NGINX

    https://www.server-world.info/en/note?os=CentOS_8&p=nginx&f=8

    Code for server

    http.createServer(app).listen(3000, () => { console.log('Server started listening on port ' + 3000); });
    

    code for .htaccess file

    RewriteEngine On
    RewriteRule ^$ http://example.com:3000/ [P,L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ http://example.com:3000/$1 [P,L]
    
    
    +++++++++++++++++++++++++
    PassengerBaseURI /
    PassengerAppRoot /home/example/app/node
    PassengerAppType node
    PassengerStartupFile index.js
    
    

  2. I think GoDaddy has restrictions on ports lower than a couple thousand. You would need sudo capabilities. I found something on it here.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search