Skip to content
← Back to Community
Custom 404
Profile icon
AgastyaSandhuja

I know that these questions have probably been answered, but is there a way to make a custom 404 page?

Answered by Zavexeon [earned 5 cycles]
View Answer
Voters
Profile icon
40476
Profile icon
DSPRINT
Profile icon
AgastyaSandhuja
Comments
hotnewtop
Profile icon
Zavexeon

Like @Vandesm14 said, it's possible with Express/Node. Really any sort of server (Django, Rails, Sinatra) would have this capability.

Are you familiar with any server side programming? If so, what language? I could give an example.

Profile icon
NigelIsCoding

@Zavexeon can u gie example for nodejs?

Profile icon
ksIsCute

theres one below this from coolcodersj @duck132912

Profile icon
CoolCoderSJ

hey there,
Heres how i did it.

Things to know before u do this

  • It wouldn't be an HTML repl, rather a node.js repl
  • you need to use something to keep your node.js server running, I used Cron Jobs
  1. Download your HTML repl as a zip and unzip it.
  2. Make a new Node.js repl and upload the unzipped folder.
  3. Rename that uploaded folder to public
  4. At this point, make sure index.js , 404.html and README.md (if u have one) are in root. All other files should be in /public, including 404.js, 404.css, and index.html.
  5. Inside of index.js (The one in root. You should have 2 js indexes, one in /index.js and one in /public/index.js. The second one supports index.html, whereas the first one supports the server.) Enter this code
require("express")().use(require("express").static(__dirname + "/public")).use((_, res) => { res.status(404).sendFile(__dirname + "/404.html"); }).listen(8080);

this should bring up your website.

Now we gotta keep the server alive

I used Cron Jobs
Once you login/signup, go to cronjobs. Make a new cron job. Enter your website domain in the first field. Unmark HTTP authentication. Set it to run every 1 minute. Save.

Voila!

Note: Every time you wanna update the website, stop the repl and re run. if its not currently running, the website wont load.

This worked for me, and I hope it worked for you too. please upvote/mark this as correct If it did.

Profile icon
PndaBoi

@CoolCoderSJ You Are Legit Amazing My Guy. Thanks A Lot!

Profile icon
PndaBoi

@CoolCoderSJ Will the site still be up if you use "always on" feature on replit?

Profile icon
i7zz

@CoolCoderSJ actually you dont need to stop the repl to update the site

Profile icon
ksIsCute

@PndaBoi yes, using js and always on will work

Profile icon
Vandesm14

Not for HTML repls, but Express/Node repls have this capability.

Profile icon
noma4321

How van I add css to the 404 page?

Profile icon
ksIsCute

as normally @noma4321

Profile icon
ash15khng

On repl.it it doesn't seem to be possible sadly. (If I'm wrong please correct me please thanks!)

Profile icon
ksIsCute
Profile icon
SixBeeps

Nope.

Profile icon
ksIsCute

thanks for the constructive and reasonable answer, unfortunately, you're wrong. @SixBeeps

Profile icon
SixBeeps

@ksIsCute Woooooww, my two year old answer is wrong???? This is incredible news! It's almost like the editor hasn't changed at all between when I posted this and now! I gotta tell everyone about how groundbreaking this is!

Profile icon
bijenmanlol

@SixBeeps it was also possible back then with a nodeJS server