# DNSError not recognized with HTTP Package installed

**URL:** <https://discourse.julialang.org/t/dnserror-not-recognized-with-http-package-installed/88557>\
**Category:** General Usage\
**Tags:** http\
**Created:** [October 11, 2022, 7:43am UTC](https://discourse.julialang.org/t/dnserror-not-recognized-with-http-package-installed/88557 "2022-10-11T07:43:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Name1](https://avatars.discourse-cdn.com/v4/letter/n/ed655f/32.png) [@Name1](https://discourse.julialang.org/u/Name1)\
**Post date:** [October 11, 2022, 7:43am UTC](https://discourse.julialang.org/t/dnserror-not-recognized-with-http-package-installed/88557/1 "2022-10-11T07:43:41Z")

</div>

Hello,

```julia
 try

          response = HTTP.request(
              "GET",
              "https://invalid-url.com.au",
              ["Content-Type" => "application/json"]; 
              require_ssl_verification=false,
          )
          println(string("dummy_method() response ", response.status))
          return JSON3.read(response.body)

catch e
        println("Error occurred: $e")
 
        if e isa(DNSError)
            println("Encountered a DNSError in Julia. Check your internet connection " *
                " and/or make sure you have a valid url")
        end

end

```

I’m trying to make a GET request to an intentionally invalid API URL address and I’m receiving some error output that looks like so:

```julia
Error occurred: DNSError: invalid-url.com.au, unknown node or service (EAI_NONAME)
ERROR: UndefVarError: DNSError not defined 

```

I’m wondering why DNSError is not defined when I try to catch it, especially given that when I print the error message it says DNSError so I haven’t pulled the name out of nowhere when I try to catch it. For clarification, when I pass a valid URL for the HTTP.request() call, my program works just fine.

Is DNSError a part of the HTTP package? If so, why does it say that DNSError is not recognized when I have the HTTP package installed and am able to run it fine with valid URL’s?

Any help would be appreciated. Hopefully I’m not missing something glaringly obvious. Cheers 🙂

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [October 11, 2022, 10:00am UTC](https://discourse.julialang.org/t/dnserror-not-recognized-with-http-package-installed/88557/2 "2022-10-11T10:00:24Z")

</div>

The name/symbol `DNSError` is not defined in _your_ code, hence the error. Inside the library, where it was constructed, it is of course defined.

In this case, `DNSError` comes from `Sockets` standard library. You can fix your snippet by adding `using Sockets` and then use `Sockets.DNSError` instead. (The name `DNSError` is not exported from `Sockets`, so it is not enough with `using Sockets` to bring in the name).

---

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [October 12, 2022, 2:45pm UTC](https://discourse.julialang.org/t/dnserror-not-recognized-with-http-package-installed/88557/3 "2022-10-12T14:45:08Z")

</div>

> [@fredrikekre](#):
>
> The name/symbol `DNSError` is not defined in _your_ code, hence the error. Inside the library

Should HTTP.jl export it? It’s an interesting case, it depends on Sockets.jl, so I’m thinking should it, and packages in general, export types of their dependencies, at least, that they can throw?
