DEV Community

Discussion on: Sending Email with Netlify Functions

Collapse
 
quantuminformation profile image
Nikos

When I run netlify dev I get


  Your application is ready~! 🚀

  âž¡ Port 5000 is taken; using 58057 instead

  - Local:      http://localhost:58057

────────────────── LOGS ──────────────────

.......

and when running netlify functions:invoke send-contact-email --no-identity



ran into an error invoking your function
FetchError: request to http://localhost:8888/.netlify/functions/send-contact-email failed, reason: connect ECONNREFUSED 127.0.0.1:8888
    at ClientRequest.<anonymous> (/Users/nikos/.nvm/versions/node/v12.13.1/lib/node_modules/netlify-cli/node_modules/node-fetch/lib/index.js:1455:11)
    at ClientRequest.emit (events.js:210:5)
    at Socket.socketErrorListener (_http_client.js:406:9)
    at Socket.emit (events.js:210:5)
    at emitErrorNT (internal/streams/destroy.js:92:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  message: 'request to http://localhost:8888/.netlify/functions/send-contact-email failed, reason: connect ECONNREFUSED 127.0.0.1:8888',
  type: 'system',
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED'```

Thread Thread
 
stevealee profile image
SteveALee • Edited

Did you resolve this? I'm getting exactly the same issue trying to call a simple function using netlify dev. Have spent ages on it.
I used 'netlify.toml' to define functions="functions/"

Is this possibly a WIndows issue?

Thread Thread
 
jennapederson profile image
Jenna Pederson

Hi Steve - Did you get this ironed out? What's the error message you're seeing?

If it's the same as the one that Marie ran into

reason: connect ECONNREFUSED 127.0.0.1:8888

then make sure that you've started up your app with netlify dev first.

If it is started, check to see what port is being used. You should see a message that the server has started. There are 3 that are started - the app, the lambda server where your functions run, and a proxy server (which is a proxy to both of those), so be sure to look for the one that is for the proxy server. The message looks like this:

Proxy server

If that port is NOT 8888, then the netlify functions:invoke call will fail since it's looking for functions on port 8888.

It doesn't look like there is an option in the command line to specify a port here, so there are a couple of options: 1) Figure out what is using port 8888 and stop it so that this will work or 2) Add the following to your [dev] block in your netlify.toml file:

port = 4444 # Port that the proxy server will listen on

This will force it to use the port you tell it to use and netlify functions:invoke will also use that port.

Make sure to change 4444 to an unused port on your system.

Thread Thread
 
stevealee profile image
SteveALee

Actually, it seems the lastest netlify-cli is broken. After a lot of head scratching I found this issue and intalled an old version and the problem went away

github.com/netlify/cli/issues/659

Thanks for answering so quickly

Thread Thread
 
jennapederson profile image
Jenna Pederson

Oh bummer! Glad you got it sorted though.