Azure-Functions icon indicating copy to clipboard operation
Azure-Functions copied to clipboard

Azure Event Grid Trigger function is not working locally and getting this error Error: connect ECONNREFUSED 127.0.0.1:7071

Open Rithwik-Bojja opened this issue 2 years ago • 5 comments

I have used below code and got error Error: connect ECONNREFUSED 127.0.0.1:7071:

using System;
using Azure.Messaging;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Extensions.Logging;

namespace FunctionApp92
{
    public class TestRithwik
    {
        private readonly ILogger<TestRithwik> _logger;

        public TestRithwik(ILogger<TestRithwik> logger)
        {
            _logger = logger;
        }

        [Function(nameof(TestRithwik))]
        public void Run([EventGridTrigger] CloudEvent cloudEvent)
        {
            _logger.LogInformation("Event type: {type}, Event subject: {subject}", cloudEvent.Type, cloudEvent.Subject);
        }
    }
}

enter image description here

Headers used:

enter image description here

Tried ngrok also but it didnt work

Rithwik-Bojja avatar Nov 27 '23 12:11 Rithwik-Bojja

Thanks for reporting pls share the all repro steps.Thanks

bhagyshricompany avatar Nov 27 '23 13:11 bhagyshricompany

I used that code and wanted to trigger eventgrid function, even added aeg-event-type header, when i run from local, i get console and then i post or get the url from postman and got that error

Rithwik-Bojja avatar Nov 28 '23 10:11 Rithwik-Bojja

just check these things. Check Local Function Runtime: Ensure that your local function runtime is up and running. You can start it by running the following command in your terminal:

bash Copy code func host start Make sure there are no errors reported in the console. If there are any issues, they will be displayed in the console output.

Check Function Port: Verify that your function is configured to run on the correct port. The default port is 7071. You can check the local.settings.json file in your function app project to confirm the port configuration.

Example:

json Copy code { "IsEncrypted": false, "Values": { "AzureWebJobsStorage": "", "FUNCTIONS_WORKER_RUNTIME": "node", "FUNCTIONS_EXTENSION_VERSION": "~3", "WEBSITE_HTTPLOGGING_RETENTION_DAYS": 7, "WEBSITE_RUN_FROM_PACKAGE": "1", "AzureWebJobsStorage": "UseDevelopmentStorage=true", "AzureWebJobsSecretStorageType": "files", "AzureWebJobsDashboard": "UseDevelopmentStorage=true", "FUNCTIONS_HTTPWORKER_PORT": 7071 } } Firewall and Antivirus: Ensure that your firewall or antivirus software is not blocking the connection on the specified port (7071). Disable the firewall temporarily and check if the issue persists.

Update Azure Functions Core Tools: Make sure you are using the latest version of Azure Functions Core Tools. You can update it using the following command:

bash Copy code npm install -g azure-functions-core-tools@3 --unsafe-perm true Ensure that your function app project is also using the latest version.

Check Dependencies: Ensure that all the dependencies in your function app project are correctly installed. Navigate to the project directory and run:

bash Copy code npm install Recreate local environment: If none of the above steps work, consider recreating your local environment. Delete the bin and obj folders, and the node_modules folder. Then run npm install again.

Restart IDE/Text Editor: If you are using an IDE or text editor, try restarting it. Sometimes, changes made to the local environment may not take effect until the IDE is restarted.

Check Network Issues: Ensure that there are no network issues on your machine. Try running other local services or applications to see if there are any network-related problems.

bhagyshricompany avatar Dec 04 '23 06:12 bhagyshricompany

No update hence closing.if have any issue pls again repoen.Thanks

bhagyshricompany avatar Jan 02 '24 09:01 bhagyshricompany

If anyone else needs help on this - I am using the latest VS 2022 update/template and the port is changed from 7071 to 7125. I discovered this in the launch setting for the project. I tested and localhost:7125 works in Postman. I believe "FUNCTIONS_HTTPWORKER_PORT" setting has no effect when running locally.

image

idbates avatar Jan 19 '24 14:01 idbates