Localhost site cannot be reached. ERR_CONNECTION_REFUSED

Hello. After running the write freely executable, I get this:

2020/07/03 08:21:34 Starting WriteFreely 0.12.0...
2020/07/03 08:21:34 Loading config.ini configuration...
2020/07/03 08:21:34 Loading templates...
2020/07/03 08:21:34 Loading pages...
2020/07/03 08:21:34 Loading user pages...
2020/07/03 08:21:34 Loading encryption keys...
2020/07/03 08:21:34 Connecting to mysql database...
2020/07/03 08:21:34 Adding {domain} routes (single user)...
2020/07/03 08:21:34 Going to serve...
2020/07/03 08:21:34 Serving on http://localhost:8080
2020/07/03 08:21:34 ---

Then I try to access http://localhost:8080 on my chrome browser and it tells me the site cannot be reached. It gives me a ERR_CONNECTION_REFUSED error. I assume it is supposed to show the default home page for the blog.

I tried clearing my browsing data, but that didn’t help. I also tried resetting permissions for localhost:8080 on chrome, but that didn’t work as well.

Any ideas?

Have you tried it on any other browser? Did it error out in the same way? Just trying to specify the problem to see if something’s up with the WriteFreely config or Chrome.

Yes I did. It errors out on Mozilla and safari as well. Mozilla says “Unable to connect Firefox can’t establish a connection to the server at localhost:8080.”

Safari says " Safari Canʼt Connect to the Server
Safari canʼt open the page “​localhost:8080” because Safari canʼt connect to the server “localhost”."

I have also tried adjusting my proxy settings according to this SO answer https://stackoverflow.com/a/7334546/4555196

Did you try

I just tried that. same result unfortunately

Hi @Dami, just to be sure, are you trying to access http://localhost:8080 from the same computer you’re running WriteFreely on?

If you’ve installed WriteFreely on a remote server and you haven’t taken extra steps like forwarding ports on your local machine, accessing localhost won’t work at all. Instead, you’ll need to type the server’s IP address into your browser, for example, where is the server IP.

Thanks for the hints. I installed write freely using an ubuntu server from digital ocean. I tried using the IP address and it gives me a different error. ERR_CONNECTION_TIMED_OUT. For some reason, the server is taking too long to respond even though the server is up and running.

That sounds to me like a firewall issue – access to port 8080 is probably blocked from the public internet. So for now you can allow access to this port through your firewall while you’re testing. And then whenever you’re ready to keep the site online, you can or install a reverse proxy like Nginx to make your site accessible on port 80 (normal HTTP port), instead of port 8080.

The firewall for my Mac is already switched off. I don’t know why it still doesn’t work. I have used port 8080 for web servers in the past and this has never happened. I wonder what’s different.

So if I understand you correctly, you installed WF on a remote machine, your Digital Ocean server, and you’re trying to access it from your Mac at home, yes?

In that case, the firewall issue @matt is talking about is not about your Mac. You need to open port 8080 on the remote server. Did you install ufw? If not, here’s the full process:

sudo apt install ufw
sudo ufw allow ssh
sudo ufw allow 8080
sudo ufw enable

Follow this carefully; it is vital that you allow SSH access first before enabling ufw, otherwise you’ll lock yourself out.

Yes that’s correct. I tried your suggestion. This is what sudo ufw status outputs:

Status: active

To                         Action      From
--                         ------      ----
22/tcp                     ALLOW       Anywhere                  
80/tcp                     ALLOW       Anywhere                  
443/tcp                    ALLOW       Anywhere                  
3306/tcp                   ALLOW       Anywhere                  
8080                       ALLOW       Anywhere                  
22/tcp (v6)                ALLOW       Anywhere (v6)             
80/tcp (v6)                ALLOW       Anywhere (v6)             
443/tcp (v6)               ALLOW       Anywhere (v6)             
3306/tcp (v6)              ALLOW       Anywhere (v6)             
8080 (v6)                  ALLOW       Anywhere (v6)     

I am now getting “This site can’t be reached. ERR_CONNECTION_REFUSED”. sigh.

I’m running out of ideas. Do you have a domain pointing to your server already? You could try setting it up behind a reverse proxy.

Not related to your question: Do you have a website running on another server that’s accessing MySQL databases on this server? If not, there’s no reason to open port 3306. Locally installed sites will be able to access the databases anyway. This poses a security risk.

Thanks for your support so far!

I don’t have a domain yet. I’ll try that. However, do you think changing the bind and host parameter in the config.ini to my server’s IP address instead of localhost would make a difference? I think I’ll try that as well.

Ok, I’ll change that. Thanks for heads up.

Ah, changing the address from localhost to my ip address fixed it :sweat_smile:! I’m thinking it’s because localhost defaults to, and writefreely was serving on and using http://my-ip-addr:8080 on the browser wasn’t enough since wf wasn’t serving the files on my servers IP address. Is this correct?

This is my current config file https://gist.github.com/Obayanju/edb55aba03a7e209e69b4a66eea0b55e#file-config-ini