简体   繁体   中英

Keep Getting Error 503 - Node.js app on A2Hosting

I have a node app that works perfectly on Heroku but not on A2Hosting nor on FastComet:

It is an express app using ejs.

The Routes are simply as follows:

//Root Route
app.get("/", function(req, res){
  res.render("index");
});

app.get("/contact", function(req, res){
    // res.send("You have reached the contact page");
    res.render("contact");
});

app.get("/about", function(req, res){
    // res.send("You have reached the contact page");
    res.render("about");
});

I keep getting an error 503 on the contact and about routes but the initial index.ejs works just fine:

My .htaccess file is simply the following:

RewriteEngine On
RewriteRule ^$ http://127.0.0.1:49555/ [P,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://127.0.0.1:49555/$1 [P,L]
DirectoryIndex views/index.ejs

The App works perfectly on my localhost as well as on Heroku. I have tried everything and cannot seem to come right with my links to contact.ejs and about.ejs.

The tags are simply:

<nav>
      <li><a href="/about">Samples</a> </li>
      <li><a href="/contact">Contact</a> </li>
    </nav>

The Index.ejs, contact.ejs and about.ejs are in a views folder.

This is the actual site on A2Hosting: http://www.digital-alchemy.solutions

And This is the site on Heroku which works perfectly: https://desolate-lowlands-92367.herokuapp.com

Any Help would be seriously appreciated.

Kind regards

Wayne

With amazing help from A2Hosting support staff, the problem was a missing line in the .htaccess file.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ views/$1.ejs [NC,L] <<<< This line was missing

RewriteEngine On
RewriteRule ^$ http://127.0.0.1:49555/ [P,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://127.0.0.1:49555/$1 [P,L]
DirectoryIndex views/index.ejs

According to their website, this error(503) can occur when resource limit is exceeded, meaning the site is exceeding the allowed resources on the server

Additionally, the error appears when:

  • Your account usage exceeds 35 simultaneous HTTP connections
  • Your account usage exceeds predefined CPU or memory limits

if you'd like more information, I have provided the link where I got the info

https://www.a2hosting.com/kb/a2-hosting-products/503-service-temporarily-unavailable-message

Good luck !

Sorry to hear you're having issues with our services though it works on Heroku.

If you email me (alex@a2hosting.com) with your primary domain name, client area email address or ticket ID, I can have our team look at what is causing the error to pop up and hopefully get to the bottom of this for you :).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM