Hi
I tried to install n8n on my server. I use nginx to make the bridge between n8n.mydomain and localhost:5678.
It works, I can access to the interface. The problem is that I have the message “Server connection could not be established. The server is down or there is a connection problem. It will reconnect automatically as soon as the backend can be reached.”
Is there a port to configure in addition to 5678?
Thanks
Hello,
hope that helps:
# How n8n should be made available. Gets by default also used to create the base of the webhook URL.
N8N_HOST="n8n.example.com"
N8N_PORT=443
N8N_PROTOCOL="https"
# If the Webhook URL is different because for example there is a reverse proxy in front of it and n8n does
# use port 4000 but is reachable from the outside via 443 it can be overwritten with:
WEBHOOK_TUNNEL_URL="https://n8n.example.com/"
# This URL gets used in the Frontend to tell it where the backend can be found
VUE_APP_URL_BASE_API="https://n8n.example.com/"
So the error you describe sounds to me like that either the environment variable VUE_APP_URL_BASE_API
is not set correctly or n8n is not reachable.
Can you tell me what happens when you click on the “+” on the right side to create a node. Does the list contain any nodes?
I use the npm package.
I configure my file .profile like this :
export N8N_HOST="localhost"
export N8N_PORT=5000
export N8N_PROTOCOL="http"
export WEBHOOK_TUNNEL_URL="http://n8n.mydomain/"
export VUE_APP_URL_BASE_API="http://n8n.mydomain/"
n8n use well my .profile. I check it by changing port.
When I click on “+”, I can select and configure nodes. But when I try to execute, I get this message :
" Problem running workflow
There was a problem running the workflow:
No active connection to server. It is maybe down."
You could just try to access n8n locally. So set:
export VUE_APP_URL_BASE_API=“http://localhost:5000/”
And then open it also via that URL.
Btw. if you need the UI to be web-accessible you can have a look at this:
https://github.com/n8n-io/n8n/issues/36#issuecomment-539647882
That should solve your problem. Because if you can see the nodes it means that the UI can reach the API. So everything is configured correctly in that regard. So then it is probably a problem with EventSource and how it does not work correctly. with your Nginx setup.
I will try to add proper documentation about that soon.
I’ didn’t see there was the same issue on github.
Thank’s for your help !
To summarize a config that works on nginx for those who need while waiting for the doc
nano /etc/nginx/sites-available/cloud.example.com
server {
listen 443 ssl;
listen [::]:443 ssl;
}
server_name cloud.example.com;
location / {
proxy_pass http://localhost:5678;
proxy_set_header Connection '';
proxy_http_version 1.1;
chunked_transfer_encoding off;
proxy_buffering off;
proxy_cache off;
}
...
If not done before:
ln -s /etc/nginx/sites-available/cloud.example.com /etc/nginx/sites-enabled/cloud.example.com
nano .bashrc
# n8n
N8N_HOST="cloud.example.com"
N8N_PROTOCOL="https"
N8N_PORT="443"
VUE_APP_URL_BASE_API="https://cloud.example.com/"
WEBHOOK_TUNNEL_URL="https://cloud.example.com/"
source ~/.profile
systemctl restart nginx.service
Then just run n8n and you can access it from https://cloud.example.com/
Thanks a lot @Arnaud!
Will make it later much easier for me to add it to the documentation if you already did the most of the work
I also put that here. It’s probably not the best way to launch n8n but it can help.
How to start automatically n8n with systemd:
nano /etc/systemd/system/n8n.service (the location depends on your os)
[Unit]
Description=n8n service
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
User=**USER**
ExecStart=/usr/bin/node /usr/lib/node_modules/n8n/bin/n8n
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl enable n8n
systemctl start n8n
systemctl status n8n
(if it’s not working see the logs with journalctl -u n8n.service -e)
@Arnaud Great, thanks! Yes, I think “not the best” is always better for people than not having any way at all
Have personally not the slightest idea about “systemd” or anything related. I am sure this solution is good enough for now and if something can get improved I hope at some point somebody will point it out.
Thanks for the proxy_pass configuration, that was helpful
Why not use pm2 for serving?
Hey @moazzam! Welcome to the community!
PM2 is something that is starting to be used with n8n. In fact, it is one of the core services in the n8n-pi. I have written an article about using PM2 and n8n which may be helpful for those working with this setup:
Is there a reason to not use systemd? You said it’s “probably not the best way”, but these days it’s probably the most standard way to handle services.
This is what worked for me. Also do not forget to open port 5678 when using AWS EC2 or lightsail
Hey @FIRE_TIKTOK,
You have a syntax issue in your nginx config file, to work out what has happened the full file would be handy.
Looking at the error though it is telling you that you have server_name in the wrong place.
maybe stupidity was written but I ask you to help me figure it out, I did it according to the example above
Hey @FIRE_TIKTOK,
you probably want the server_name
and location
directives inside the server
block.
Here’s an example config I have used in the past:
server {
server_name your.domain.name;
location / {
proxy_pass http://localhost:5678;
proxy_set_header Connection '';
proxy_http_version 1.1;
chunked_transfer_encoding off;
proxy_buffering off;
proxy_cache off;
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/your.domain.name/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/your.domain.name/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
in the sites-available and sites-enabled folders do you write this code in files with a domain name? What did you do with the “defaults” files?