Infura Websockets Connection Fails Within Docker Container

I’m working on a project that uses Infura websockets for event listening. When running outside of a docker container I can connect just fine using websockets, and when running inside of a docker container I can connect without websockets just fine. In addition running the docker container with host networking mode works. But when attempting to connect from within the docker container using websockets without host networking mode I get the following error

goroutine 1 [running]:
main.main()
	/BUILD/cmd/main.go:143 +0x554
panic: dial tcp: lookup mainnet.infura.io on 127.0.0.11:53: no such host

Hi @bonedaddy, and welcome to the Infura community!

From this thread with people having the same kind of issue, it sounds like you may need to set your own hostname instead of using a docker-compose service. I would give that a try.

Alternatively, your DATABASE_URL may be missing “@db,” similar to this person’s thread.

If those don’t work, let us know and we’ll keep working with you!

Interesting, I will try these suggestions and report back. Thanks!

Looks like it was an issue caused by my DNS configuration. I was using a VPN at the time when i was running the test and that must’ve caused the problem, as trying without the VPN hasnt caused any issues.

1 Like