Topic: Contact form connection refused when trying to submit

suxxez free asked 6 years ago


Hello, I am trying to follow this guide for a contact form in my angular application. However, when I press the SEND button, I get this error message in Chrome:   OPTIONS http://localhost:3000/send net::ERR_CONNECTION_REFUSED   I'm not posting any code snippets because it's pretty much exactly like in the guide. Anybody knows why that happens? In the server.js I start up the express server on port 3000, so why does it say connection refused?   Thank you.

Damian Gemza staff answered 6 years ago


Dear suxxez, I have tried to reproduce your problem both on Chrome and Firefox on Ubuntu, but for me, everything was working fine. Please check, if you have filled-up server.js files with the necessary information: lines 14 and 15 - login  and password for mailbox from which you want to send emails, and line 40 - email on which users can reply to you. Also please check, if you have added FormsModule, ReactiveFormsModule, and BrowserAnimationsModule in your app.module.ts file Best Regards, Damian

suxxez free commented 6 years ago

Hello, so I just found the problem. I had to start the server in the terminal with "node server.js". Can I somehow implement that into my main program, so that it gets started automatically when I run "ng serve"?


Damian Gemza staff commented 6 years ago

Dear suxxez,

You can define the new script in package.json, like "run", and place there node server.js and ng serve commands.

This script would look like this one: "run": "node server.js && ng serve"

Best Regards,

Damian


suxxez free commented 6 years ago

Thank you very much!


Wensllei Sulbaran Matos free commented 4 years ago

Hi Damian Gemza, I try to define the script in my package.json but I cannot solve the error.

"scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "test": "ng test", "lint": "ng lint", "run": "node server.js && ng serve", "e2e": "ng e2e" },

What am I doing wrong?


Arkadiusz Idzikowski staff commented 4 years ago

What is the error message?


Wensllei Sulbaran Matos free commented 4 years ago

Hi Arkadiusz Idzikowski

Error message: POST http://localhost:3000/send net::ERR_CONNECTION_REFUSED

zone-evergreen.js:2952



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Resolved

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB Angular
  • MDB Version: 6.2.3
  • Device: PC
  • Browser: Chrome
  • OS: Windows 10
  • Provided sample code: No
  • Provided link: Yes