DEV Community

Cover image for Page Not Found Error on Netlify Reactjs React Router solved

Page Not Found Error on Netlify Reactjs React Router solved

Rajesh Royal on June 04, 2020

So you made a Single Page Application and It’s working great on localhost npm or yarn server. And now you made a build of this site and deploy it t...
Collapse
 
mellim profile image
Mel Lim • Edited

Thanks for this, Rajesh! You definitely put me on the right track. I found the _redirects file didn't seem to like working with my netlify.toml, which I was already using to redirect API calls to my backend. I found this sample code to add to my netlify.toml file in the Netlify documentation:

[COMMENT] The following redirect is intended for use with most SPAs that handle routing internally.

[[redirects]]
from = "/*"
to = "/index.html"
status = 200

Link to documentation here: docs.netlify.com/configure-builds/...

Tip: scroll through the sample file that is provided or use find on your browser as it is kind of lost in a sea of other sample code.

Collapse
 
rajeshroyal profile image
Rajesh Royal

Thanks @mellim
This detailed comment is definitely going to help somebody.

Collapse
 
humblecodes profile image
humble-codes

this did work for me when i deployed it on Netlify platform, but failed to work when deployed the same static site on Render platform. Can you explain, how to solve the issue while deploying on render platform

Thread Thread
 
rajeshroyal profile image
Rajesh Royal

I never worked with this platform before.

Collapse
 
imehusoro profile image
Imeh Usoro

This was my solution. Thanks a lot, Mel!

Collapse
 
ariiie_arie profile image
Arieee

I tried this and still did not work

Collapse
 
rajeshroyal profile image
Rajesh Royal

Maybe you missed any config or having some other issue with project. please provide more information so people from comments can also help. Thanks.

Collapse
 
anabeatrizzz profile image
Ana Beatriz

For me too.

Collapse
 
felipekafuri profile image
Felipe Ramos Kafuri

Thanks thats saved me haha

Collapse
 
rajeshroyal profile image
Rajesh Royal

you're welcome 😀

Collapse
 
codeclassifiers profile image
codeclassifiers

Thank you so much for this fix. This is a really useful tip.

Collapse
 
dhruvindev profile image
Dhruvin • Edited

very helpful

Collapse
 
animeshsinghweb profile image
Animesh Singh

Thanks! Worked awesome.
I had missed the note to add _redirects to public/ folder. Fixed and good!

Collapse
 
zaqar profile image
Za-Qar

This is very helpful, thank you!

Collapse
 
jonatasoc profile image
Jonatas de Oliveira Coêlho

Hey, Rajesh! You helped me a lot! Thank you very much!

Collapse
 
melindacardenas profile image
Melinda Cardenas

this worked for me! thank you :-)

Collapse
 
roxanaflorea profile image
Roxana F

You are a life saver!!! Thanks from the bottom of my heart <3

Collapse
 
rajeshroyal profile image
Rajesh Royal

Your welcome sir 😉

Collapse
 
matcs06 profile image
Mateus Costa Silva

You saved me!! Thank you so much!!!

Collapse
 
javila35 profile image
Joe Avila

You are doing god's work

Collapse
 
rajeshroyal profile image
Rajesh Royal

heheheh 😄

Collapse
 
hecthorl profile image
hector vargas

thanks a lot man

Collapse
 
kmanadkat profile image
Krupesh Anadkat

Thanks man :)

Collapse
 
rajeshroyal profile image
Rajesh Royal

you're welcome 😀

Collapse
 
mehmetcanaygun profile image
Can

Thank you! That was what I needed.

Collapse
 
sahla profile image
Sahl Khalifa

Thank you. Simple & effective

Collapse
 
devcoder profile image
devcoder

life saver!, thanks for this, i spent days researching this issue and was about to give up

Collapse
 
hamzaaouni profile image
Hamza-Aouni

Arigato !!

Collapse
 
jarodsim profile image
Jarod Mateus de Sousa Cavalcante

love u

Collapse
 
mrisrael profile image
MrIsrael

Thanks a lot, man!

Collapse
 
nutlope profile image
Hassan El Mghari

You are a live saver my man

Collapse
 
zubisofts profile image
Anyanwu Nzubechi Godswill

Wow! Thanks a lot man!

Collapse
 
kizito007 profile image
Kizito Nwaka

Thanks 🙏

Collapse
 
guimaraesmiguel profile image
Miguel Guimaraes

I had the same issue and it worked for me. Thank you man!

Collapse
 
rodieche profile image
Rodolfo

It works. Thanks!

Collapse
 
devvsakib profile image
Sakib Ahmed

hi, why it doesnt work on custom domain?

Collapse
 
devgrammer profile image
Abhinav Deep Rastogi

You saved my life Brother ! Lots of love <3

Collapse
 
srishty profile image
Srishty Mangutte • Edited

Thanks for this post. It actually helped a lot !

Collapse
 
georgeraveen profile image
George Raveen

Thanks a lot. Solved my problem.

Collapse
 
sauravkumarjhanitw profile image
SauravKumarJhaNITW

Helpful!

Collapse
 
bayorwor profile image
bayorwor

Saved my life

Collapse
 
ashiqsultan profile image
Mohamed Ashiq Sultan

Thanks, for sharing

Collapse
 
mahmodulshahin profile image
Mahmodul Shahin

thank you for save my project. haha :)

Collapse
 
gtalinn profile image
Aruj

Thanks for this concise solution. It saved me quite a lot of time!

Collapse
 
olney1 profile image
Ben

I have been looking everywhere for a solution thank you!

Collapse
 
as_e7946ce3c83 profile image
Adam Sheridan

You sir are a life saver! Thank you!!!

Collapse
 
lucasfrazier profile image
Lucas Frazier

Thank you. This solved my problem.

Collapse
 
mrpaulishaili profile image
Paul C. Ishaili

This is really helpful! Permission to share on my dev page

Collapse
 
thenriquedb profile image
Thiago Henrique Domingues

Thanks man!

Collapse
 
didibonocore profile image
didiBonocore

It worked! Thanks, really good explanation.

Collapse
 
rizwanmushtaq profile image
RizwanMushtaq

thanks

Collapse
 
ngochieu276 profile image
ngochieu276

thanks Rajesh, perfect answer

Collapse
 
khethelogp profile image
Khethelo Ndhlala

Thank you very much Rajesh ⭐

Collapse
 
neeleshwark17 profile image
Neeleshwar

That worked!, Thanks a lot man

Collapse
 
protik111 profile image
Rafiur Rahman Protik

It's working! Thanks Rajesh.

Collapse
 
matta profile image
mohamed atta

Thanks man 🙏🙏🙏

Collapse
 
largenty profile image
Largenty

You are the best!

Collapse
 
osamakhalil98 profile image
osama

Thanks man <3

Collapse
 
spiropoulos94 profile image
NikosSp

You are awesome, thanks!!!
I have on question though, will I have the same problem if I deploy my app to another hosting provider?
Or is it a strictly netlify issue??

Collapse
 
rajeshroyal profile image
Rajesh Royal

depends on the configuration of that host, please read their documentation related to routing.

Collapse
 
harshmathurx profile image
Harsh Mathur

THANK YOU SO MUCH

Collapse
 
ijlalansari1122 profile image
ijlal ansari

hey there still not working

Collapse
 
rohits20 profile image
Rohits20

Thanks bro!! It worked

Collapse
 
renanlido profile image
Renan Oliveira

Thanks man! It's works for me!

Collapse
 
cpx2017 profile image
cpx2017

Hello, I'm newbie of Netlify and use React JS for almost default frontend framework. This solution article is helpful. Thanks

Collapse
 
diyafury profile image
Diyafury

Saved me! thank you!

Collapse
 
kshitiz111 profile image
Kshitiz Pal

Thanks. It worked for me.

Collapse
 
hxxtae profile image
Heetae Kim

Thanks @mellim 👍

Collapse
 
khalilonline99 profile image
Ibrahim Khalil

Thanks for sharing. This worked fine.

Collapse
 
kotesh_mudila profile image
Kotesh_🔯

Awesome!
Sorted my issue and just started writing a well explained PR, by resolving this issue
Thank you Rajesh 🤝

Collapse
 
abeysaji2000 profile image
Abey Saji Kurian

Thank you soo much ! it work perfectly

Collapse
 
ksd8123 profile image
niko

Thank you very much