Next.js Discord

Discord Forum

Error: Connection Closed

Answered
Abhii posted this in #help-forum
Open in Discord
Avatar
Hello, I have been building this app it’s working fine on local , it breaks in production on routes like products/[id] and categories/[slug]. In console its shows
Error : Connection closed

https://store-thing.vercel.app/categories
Answered by B33fb0n3
then it looks like the api that you are using is broken (or at least serverless hosted) and then your connection is broken, because the server was shut downed. If I would be you, I would create a constants.ts file that contains some products and then use that. It's much more reliable (or of course your own database)
View full answer

26 Replies

Avatar
@Abhii solved?
Avatar
I have removed the code where database being used and crashing has stopped, however its still crashing at some pages. I'm still working on those pages to identify whats causing this.
Thank you it was great help , can you please tell how can i fix this as im using mongodb.
Avatar
the last one , im not getting any error on local so its hard to find whats happening here.
https://github.com/Abhii5496/store-thing , repo if you want to take a look .
Image
Avatar
yes
when i hard refresh it works
Avatar
when does this error pop up? When you click something? Hover something? When you interact with something? ...
Avatar
when i navigate to any product detail page (/products/1)
Avatar
@Abhii when i navigate to any product detail page (/products/1)
Avatar
can you refresh the current page (should work, as you said) and directly navigate to any other product detail page?
Avatar
yes
well now im getting this
Image
fakestore api is down , i'll try it later
Avatar
@Abhii well now im getting this
Avatar
ok its working now
Avatar
its working fine
Avatar
@Abhii its working fine
Avatar
but when you refresh the page, wait around 15 seconds and then navigate, it shows the error?
Avatar
thats right
Avatar
no , after removing these two it works well.
Avatar
@Abhii no , after removing these two it works well.
Avatar
then it looks like the api that you are using is broken (or at least serverless hosted) and then your connection is broken, because the server was shut downed. If I would be you, I would create a constants.ts file that contains some products and then use that. It's much more reliable (or of course your own database)
Answer
Avatar
@Abhii solved?
Avatar
sure thing