500 Internal Server Error on Netlify Form Submission

Hi there,

Whenever I submit my contact form on https://marblingmagpie.netlify.app/ I get a 500 Internal Server Error response.

Netlify forms are enabled on the project, but the Usage and Configuration section seems to be stuck in a loading state. Disabling and re-enabling Netlify Forms did not help.

The project is built in Next and uses (as far as I can tell) all the correct elements and attributes to set up a working form. I have also gone through the Netlify Forms support guide on this forum and not been able to resolve the issue.

The HTML for the form is:

<form name="contact" data-netlify="true" method="POST">
   <input type="hidden" name="form-name" value="contact">
   <div class="px-6 sm:pl-0 sm:pr-9">
      <div class="footer-form-field">
        <label for="name" class="footer-form-label">Enter Your Name</label>
        <input class="footer-form-input" id="name" type="text" placeholder="" aria-required="false" maxlength="100" name="name">
      </div>
      <div class="footer-form-field">
        <label for="email" class="footer-form-label" aria-required="true">Enter Your Email</label>
        <input class="footer-form-input" id="email" type="email" required="" aria-required="true" pattern="^.+@.+\.[a-zA-Z]{2,63}$" maxlength="250" name="email">
      </div>
      <div class="footer-form-field">
        <label for="subject" class="footer-form-label">Enter Your Subject</label>
        <input class="footer-form-input" id="subject" type="text" placeholder="" aria-required="false" name="subject">
      </div>
      <div class="footer-form-field">
        <label for="message" class="footer-form-label">Message</label>
        <textarea class="footer-form-input h-32" id="message" name="message" placeholder="" aria-required="true"></textarea>
      </div>
      <div aria-disabled="false" class="flex justify-end mt-4 mb-10">
        <button class="btn-main w-full p-1 w-full sm:w-32" aria-disabled="false" type="submit">
          <span>Submit</span>
        </button>
      </div>
   </div>
</form>

I previosly had an action attribute on the form set to “/success”, but that was not working either and gave me the same error:

@test-user This is a Next.js error:

A bit further down in the network tab, you can see it is X-Powered-By

So you likely have two issues:

  1. The form is in JavaScript, not HTML, so isn’t even being detected post-build.
  2. The form is being submitted to a route handled by Next.js, not one that Netlify handles.

It’s addressed on the Forms Setup page in the documentation:
https://docs.netlify.com/forms/setup/

Specifically here:
https://docs.netlify.com/forms/setup/#forms-for-next-js-or-ssr-frameworks

Also in the Troubleshooting Tips:
https://docs.netlify.com/forms/troubleshooting-tips/#next-js-runtime-v5-support

There is more information on the Next.js page in the documentation:
https://docs.netlify.com/frameworks/next-js/overview/

Underneath ‘Limitations’:
https://docs.netlify.com/frameworks/next-js/overview/#limitations

Which links to this external documentation that walks you through working with Next.js + Netlify Forms:
https://opennext.js.org/netlify/forms