Skip to content

Commit 64d0f11

Browse files
authored
docs: update port example (#3391)
1 parent 3a1898c commit 64d0f11

File tree

1 file changed

+39
-6
lines changed

1 file changed

+39
-6
lines changed

examples/cli/host-and-port/README.md

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,79 @@
33
You may choose to wish to change the host and port on which `webpack-dev-server`
44
will run. The `host` and `port` options allow for that.
55

6-
## IPv4
6+
## host
7+
8+
### IPv4
79

810
```console
911
npx webpack serve --open-target --port 5000 --host 0.0.0.0
1012
```
1113

12-
## IPv6
14+
### IPv6
1315

1416
_This also works with IPv6_
1517

1618
```console
1719
npx webpack serve --open-target --port 5000 --host ::
1820
```
1921

20-
## local-ip
22+
### local-ip
2123

2224
Specifying `local-ip` as `host` will try to resolve the `host` option as your local `IPv4` address if available, if `IPv4` is not available it will try to resolve your local `IPv6` address.
2325

2426
```console
2527
npx webpack serve --open-target --port 5000 --host local-ip
2628
```
2729

28-
## local-ipv4
30+
### local-ipv4
2931

3032
Specifying `local-ipv4` as `host` will try to resolve the `host` option as your local `IPv4` address.
3133

3234
```console
3335
npx webpack serve --open-target --port 5000 --host local-ipv4
3436
```
3537

36-
## local-ipv6
38+
### local-ipv6
3739

3840
Specifying `local-ipv6` as `host` will try to resolve the `host` option as your local `IPv6` address.
3941

4042
```console
4143
npx webpack serve --open-target --port 5000 --host local-ipv6
4244
```
4345

44-
## What Should Happen
46+
#### What Should Happen
4547

4648
1. The script should open `http://0.0.0.0:5000/` if specifying the IPv4 option,
4749
or `http://[::]:5000/` for IPv6, in your default browser.
4850
2. You should see the text on the page itself change to read `Success!`.
51+
52+
## port
53+
54+
### specific port
55+
56+
Tell the server to connect to a specific port with the following:
57+
58+
```console
59+
npx webpack serve --open-target --port 9000
60+
```
61+
62+
#### What Should Happen
63+
64+
1. The script should open `http://localhost:9000/` in your default browser.
65+
2. You should see the text on the page itself change to read `Success!`.
66+
67+
### auto
68+
69+
Specifying `auto` as `port` will try to connect the server to the default port `8080` and if not available it will automatically search for another free port.
70+
71+
```console
72+
npx webpack serve --open-target --port auto
73+
```
74+
75+
#### What Should Happen
76+
77+
1. The script should open `http://localhost:8080/` in your default browser.
78+
2. You should see the text on the page itself change to read `Success!`.
79+
3. Keep the server open and switch to a new terminal window.
80+
4. Run the script once again.
81+
5. The script should open `http://localhost:8081/` (or any other port if it is not free) in your default browser.

0 commit comments

Comments
 (0)