Deployment Issues

Hello guys. I am currently facing an issue with my Next.js app deployment. After following a guide from netlify’s blog on how to create Server-side rendered App using netlify for Next.js, I was able to have a successful build but my site seems not to be working.

The site is currently at The error message will be pasted below.

"errorType": "Runtime.UnhandledPromiseRejection",
"errorMessage": "FetchError: request to http://localhost:3000/api/notes failed, reason: connect ECONNREFUSED",
"trace": [
"Runtime.UnhandledPromiseRejection: FetchError: request to http://localhost:3000/api/notes failed, reason: connect ECONNREFUSED",
"    at process.<anonymous> (/var/runtime/index.js:35:15)",
"    at process.emit (events.js:315:20)",
"    at processPromiseRejections (internal/process/promises.js:209:33)",
"    at processTicksAndRejections (internal/process/task_queues.js:98:32)"

hi there,

do you have a hardcoded URL that points to your localhost somewhere? that seems to be what this indicates:

request to http://localhost:3000/api/notes

You can’t make a call like that from a production server - it has no idea where localhost is. Can you use a relative URL instead?

Hi there, thanks for the feedback. However, i’m having a bit of a hard time understanding the relative url point you raised.

Please how am i supposed to go about that? Thank you once again

do you have a link in your code somewhere to: http://localhost:3000/api/notes?

if yes, then that won’t work on a live server and probably needs to go to something like:

/api/notes instead.

Yes i do have a link to http://localhost:3000/api/notes . However i tried doing what you suggested but i couldn’t get it to work. Here is an example.

Index.getInitialProps = async () => {

  const res = await fetch('http://localhost:3000/api/notes')

  const { data } = await res.json()

  return { notes: data }


export default Index

I have some other files that i am making requests like this. How would i refractor this to be production ready? Thank you for your time.

so, have you tried changing http://localhost:3000/api/notes to /api/notes then?