Reputation: 1080
I'm having the following issue:
Error: connect ETIMEDOUT 209.85.234.27:25
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1159:16) {
when running the following code on GCP (both Cloud Functions and Cloud Run fail):
const verifier = require('email-verify')
const express = require('express')
const app = express()
/**
* Verify an email address
*/
app.post('/verify', async (request, response, _next) => {
const email = request.query.email
console.log(`Verifying ${email}`)
const isValid = await new Promise(function (resolve, _reject) {
if (!email || typeof email !== 'string') {
return resolve(false)
}
verifier.verify(email, function (err, info) {
if (err) {
console.error(err)
return resolve(false)
}
return resolve(info.success)
})
})
response.json({ valid: isValid, email: typeof email === 'string' ? email : '' })
})
const port = process.env.PORT || 8080
app.listen(port, () => {
console.log(`Listening on port ${port}`)
})
I feel like GCP timeouts when trying to connect to distant servers, but I don't find any resource online to help me debug this. Does anyone already got this kind of issue?
Upvotes: 0
Views: 828
Reputation: 15276
If we look at the error message, we see that it is attempting to connect to an external service at port 25. Google always blocks outbound requests to port 25. You can find this documented and relevant alternatives at this page:
Sending email from an instance
In addition, here is a good search query (here on StackOverflow) for similar questions and answers.
Upvotes: 2