• Skip to main content
  • Skip to search
  • Skip to select language
    • Technologies Overview
    • HTML
    • CSS
    • JavaScript
    • Graphics
    • HTTP
    • APIs
    • Browser Extensions
    • MathML
    • Learn web development
    • Tutorials
    • References
    • Developer Guides
    • Accessibility
    • Game development
    • ...more docs
    • Send Feedback
    • Contribute to MDN
    • Report a content issue 🌐
    • Report a platform issue 🌐
  1. Web technology for developers
  2. Web APIs
  3. URL
  4. URL.port
  • Change language

Table of contents

  • Value
  • Examples
  • Specifications
  • Browser compatibility
  • See also

URL.port

The port property of the URL interface is a USVString containing the port number of the URL. If the URL does not contain an explicit port number, it will be set to ''.

Note: This feature is available in Web Workers

Value

A USVString.

Examples

const url = new URL('https://mydomain.com:80/svn/Repos/');
console.log(url.port); // Logs '80'

Specifications

Specification
URL Standard
# dom-url-port

Browser compatibility

BCD tables only load in the browser

See also

  • The URL interface it belongs to.

Found a problem with this page?

  • Edit on GitHub
  • Source on GitHub
  • Report a problem with this content on GitHub
  • Want to fix the problem yourself? See our Contribution guide.

Last modified: Mar 25, 2022, by MDN contributors

Change your language

Related Topics

  1. URL API
  2. URL
  3. Constructor
    1. URL()
  4. Properties
    1. hash
    2. host
    3. hostname
    4. href
    5. origin
    6. password
    7. pathname
    8. port
    9. protocol
    10. search
    11. searchParams
    12. username
  5. Methods
    1. createObjectURL()
    2. revokeObjectURL()
    3. toJSON()
    4. toString()
  6. Related pages for URL API
    1. URLSearchParams
  • Web Technologies
  • Learn Web Development
  • About MDN
  • Feedback
  • About
  • MDN Web Docs Store
  • Contact Us
  • Firefox

MDN

  • MDN on Twitter
  • MDN on Github

Mozilla

  • Mozilla on Twitter
  • Mozilla on Instagram

© 2005-2022 Mozilla and individual contributors. Content is available under these licenses.

  • Terms
  • Privacy
  • Cookies