Ngrok cannot connect to a website running on local machine with Docker

I’ve configured a Symfony app to use Caddy installed through Docker.

To configure the Docker environment I used the Symfony Docker config by Dunglas.

When I connect to mywebsite.localhost I can see the page.

Now, I start a tunnel through ngrok with this command:

ngrok http https://myapp.localhost --host-header=rewrite

Once the tunnel starts, if I try to go to the generated tunnel , I get this error:


Traffic was successfully tunneled to the ngrok agent, but the agent failed to establish a connection to the upstream web service at myapp.localhost:443. The error encountered was:

dial tcp: lookup myapp.localhost: no such host

Get help with this error

If I click on the link to my local app in the error (“myapp.localhost:443”), the page only reports this:

Client sent an HTTP request to an HTTPS server.

But if I go to https://myapp.localhost, the app works as expected.

I supposed the problem was with the scheme (“http” instead of “https”), so I added --scheme=https to the command, running this:

ngrok http https://olympus.localhost --host-header=rewrite --scheme=https

Also adding the explicit scheme configuration, I continue to receive the errors mentioned above.

My Caddyfile is as follows:

    # Debug




route {
    root * /srv/app/public
    mercure {
        # Transport to use (default to Bolt)
        transport_url {$MERCURE_TRANSPORT_URL:bolt:///data/mercure.db}
        # Publisher JWT key
        # Subscriber JWT key
        # Allow anonymous subscribers (double-check that it's what you want)
        # Enable the subscription API (double-check that it's what you want)
        # Extra directives
    php_fastcgi unix//var/run/php/php-fpm.sock
    encode zstd gzip

As you can see, nothing complex nor “strange”.

Any ideas about why the tunnel created with ngork cannot correctly route requests to Caddy and my app?

If you need further information, please, feel free to ask me them and I will add them ASAP!

Thank you

That’s an DNS lookup error.
You could add myapp.localhost to /etc/hosts and hope ngrok will pick it up.
Or just use localhost everywhere instead of myapp.localhost

1 Like

Perfect: it works!

Many thank you and happy holidays!

1 Like

This topic was automatically closed after 30 days. New replies are no longer allowed.