Self hosted n8n trying to connect with self hosted discourse

Hi all

I’m new to n8n, and I’m trying to connect a self hosted discourse (both running locally in different ports) to the workflow.

API key was created, but when I try to save the info in n8n and execute the step things do not work. The API key was validated and ran correctly in the terminal.

Should it not work with localhost? Any recommendations?

Thanks a lot in advance for any information provided :slight_smile:

You likely shouldn’t be using 127.0.0.1 address. Are you running discourse in a docker container or what do you mean by “locally”? Tell us more about how exactly you are running both n8n and discourse.

Correct, I’m running it in a docker container (.devcontainer to be more specific)

and n8n? how do you run that?

Also a docker container

Running it with the docker compose command…

From your host, do you access discourse via 127.0.0.1?

If so then you can access discourse from n8n with either:

  • http://host.docker.internal:4201 (this would normally work with Docker Desktop for Mac and Windows)
  • http://host_docker_network_interface:4201 (you need to find you docker interface of your host first)

I would also consider running discourse in a separate docker container, alongside your other container within docker compose network.

2 Likes

Exactly. The URL I access from the browser is like: http://127.0.0.1:<PORT_NUM> or localhost:<PORT_NUM> Similar approach to open my n8n instance.

Ok, if you are running your n8n in docker desktop for win or mac, you could try http://host.docker.internal:4201

I’m running it on linux, via command terminal. I will try to find this:

Then add that in the URL field of my sent screenshot.

It would be much easier if you ran your discourse in a separate container alongside n8n container from the same docker-compose infra though.

I’m not usre I understood the following part:

They are both running in different containers. I’m checking how to get the docker interface address as you have mentioned. Thanks for your replies and help

on that linux machine:

ip addr show docker0
1 Like

Ahhh okay, both running from same docker compose file… This I got it. :slight_smile: Thanks

Tried adding the address found as response for this command, but still get the error:

The service refused the connection - perhaps it is offline

this could mean that the discourse container is only exposed for 127.0.0.1
on that linux machine run netstat -tulnp and find the line with :4201

or netstat -tulnp | grep 4201

Yeah, tried and only 127.0.0.1 is mapped to that port.

This is why I said it would be easier to run that container with the rest of containers. If you wish to keep running it as devcontainer, you will need to make VS Code (this is what you are running your devcontainer from, right?) listen on more ips than just 127.0.0.1. Probably this is how.

1 Like

Hi @jabbson ,

I really appreciated your time and help :slight_smile:

Got it sorted. I’ve done the config on vscode you recommended, used the correct host_docker_network_interface, and I also had to restart the docker service in my machine as it was giving some Error: getaddrinfo EAI_AGAIN error for the docker network address.

All the best

1 Like

Great job, glad I could help.

1 Like